![]() | ![]() |
Home |
|
|
|
| Chapter 2: The Embedded SQL Interface |
|
| Library functions |
|
| Interface initialization functions |
This section lists the functions that initialize and release the interface.
unsigned short db_init( struct sqlca *sqlca );
This function initializes the database interface library. This function must be called before any other library call is made, and before any Embedded SQL command is executed. The resources the interface library requires for your program are allocated and initialized on this call.
Use db_fini to free the resources at the end of your program. If there are any errors during processing, they are returned in the SQLCA and 0 is returned. If there are no errors, a non-zero value is returned and you can begin using Embedded SQL commands and functions.
In most cases, this function should be called only once (passing the address of the global sqlca variable defined in the sqlca.h header file). If you are writing a DLL or an application that has multiple threads using Embedded SQL, call db_init once for each SQLCA that is being used (see SQLCA management for multi-threaded or reentrant code ).
WARNING!Caution
Failure to call db_fini for each db_init on NetWare can cause the database server to fail, and the NetWare file server to fail.
unsigned short db_fini( struct sqlca *sqlca );
This function frees resources used by the database interface or DLL. You must not make any other library calls or execute any Embedded SQL commands after db_fini is called. If there are any errors during processing, they are returned in the SQLCA and 0 is returned. If there are no errors, a non-zero value is returned.
You need to call db_fini once for each SQLCA being used.
WARNING!Caution
Failure to call db_fini for each db_init on NetWare can cause the database server to fail, and the NetWare file server to fail.
|
|