|
The mi_open() function establishes a connection to a database server and opens a database.
db_name | is the name of the database to open. |
user_name | is the name of the user account on the server computer. |
user_passwd | is the account password. |
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:
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().
MI_CONNECTION * | is a pointer to the connection descriptor for the newly established connection. |
NULL | indicates that the function was not successful. |
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.