informix
Informix DataBlade API Programmer's Manual
DataBlade API Function Descriptions

mi_open()

The mi_open() function establishes a connection to a database server and opens a database.

Syntax

Usage

The mi_open() function creates a connection descriptor for a connection. This function is a constructor function for a connection descriptor. The DataBlade API module can pass the new connection descriptor to subsequent routines that require a connection. The mi_open() function also initializes the DataBlade API when it is the first DataBlade API function in a client LIBMI application or C UDR routine.

For a C UDR, the mi_open() function establishes a UDR connection, which gives the UDR access to the client session that executed the SQL statement that initiated the UDR. To open a UDR connection, pass all three arguments to mi_open() as the NULL-valued pointers. The mi_open() function allocates a new connection descriptor in the PER_COMMAND memory duration.

For a client LIBMI application, the mi_open() function establishes a connection to the default database server and opens the db_name database. You can also specify the user account with the user_name and user_passwd arguments. This connection begins a client session. The mi_open() function allocates a new connection descriptor in a duration of the client session.

If a client LIBMI application set default database parameters with mi_set_default_database_info(), mi_open() uses these defaults when it receives NULL-valued pointers as arguments. Otherwise, mi_open() uses the following default values:

mi_open() Argument Default Used When Argument is NULL
Database name None
User name The name of the user login account that is running the executable file.
Password The password of the user account that is running the executable file.

If the client LIBMI application uses a shared-memory communication, it can only establish one connection per application.

The mi_open() function uses the default connection parameters to establish a client connection. To specify a nondefault system name for a client session, call the mi_sysname() function before the call to mi_open().

Important: Do not specify the system name in the format "dbname@servername" within the "dbname" argument of the mi_open() function. Instead, call the mi_sysname() function before mi_open().

Return Values

MI_CONNECTION * is a pointer to the connection descriptor for the newly established connection.
NULL indicates that the function was not successful.

Related Topics

See the descriptions of the following functions: mi_close(), mi_login(), mi_server_connect(), mi_set_default_database_info(), and mi_sysname().

For information about database parameters, see Using Database Parameters.


Informix DataBlade API Programmer's Manual, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved