Connecting to a database server is done with one call to OCI_ConnectionCreate().
OCI_ConnectionFree() closes the established connection.
Connection properties are accessible through a set of functions
#include "ocilib.h" int main(void) { OCI_Connection *cn; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); printf("Server major version : %i\n", OCI_GetServerMajorVersion(cn)); printf("Server minor version : %i\n", OCI_GetServerMinorVersion(cn)); printf("Server revision version : %i\n\n", OCI_GetServerRevisionVersion(cn)); printf("Connection version : %i\n\n", OCI_GetVersionConnection(cn)); OCI_Cleanup(); return EXIT_SUCCESS; }
Functions | |
OCI_EXPORT OCI_Connection *OCI_API | OCI_ConnectionCreate (const mtext *db, const mtext *user, const mtext *pwd, unsigned int mode) |
Create a physical connection to an Oracle database server. | |
OCI_EXPORT boolean OCI_API | OCI_ConnectionFree (OCI_Connection *con) |
Close a physical connection to an Oracle database server. | |
OCI_EXPORT boolean OCI_API | OCI_IsConnected (OCI_Connection *con) |
Returns TRUE is the given connection is still connected otherwise FALSE. | |
OCI_EXPORT void *OCI_API | OCI_GetUserData (OCI_Connection *con) |
Return the pointer to user data previously associated with the connection. | |
OCI_EXPORT boolean OCI_API | OCI_SetUserData (OCI_Connection *con, void *data) |
Associate a pointer to user data to the given connection. | |
OCI_EXPORT boolean OCI_API | OCI_SetSessionTag (OCI_Connection *con, const mtext *tag) |
Associate a tag to the given connection/session. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetSessionTag (OCI_Connection *con) |
Return the tag associated the the given connection. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetDatabase (OCI_Connection *con) |
Return the name of the connected database/service name. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetUserName (OCI_Connection *con) |
Return the current logged user name. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetPassword (OCI_Connection *con) |
Return the current logged user password. | |
OCI_EXPORT boolean OCI_API | OCI_SetPassword (OCI_Connection *con, const mtext *password) |
Change the password of the logged user. | |
OCI_EXPORT boolean OCI_API | OCI_SetUserPassword (const mtext *db, const mtext *user, const mtext *pwd, const mtext *new_pwd) |
Change the password of the given user on the given database. | |
OCI_EXPORT unsigned int OCI_API | OCI_GetSessionMode (OCI_Connection *con) |
Return the current session mode. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetVersionServer (OCI_Connection *con) |
Return the connected database server version. | |
OCI_EXPORT unsigned int OCI_API | OCI_GetServerMajorVersion (OCI_Connection *con) |
Return the major version number of the connected database server. | |
OCI_EXPORT unsigned int OCI_API | OCI_GetServerMinorVersion (OCI_Connection *con) |
Return the minor version number of the connected database server. | |
OCI_EXPORT unsigned int OCI_API | OCI_GetServerRevisionVersion (OCI_Connection *con) |
Return the revision version number of the connected database server. | |
OCI_EXPORT boolean OCI_API | OCI_SetDefaultFormatDate (OCI_Connection *con, const mtext *format) |
Set the date format for implicit string / date conversions. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetDefaultFormatDate (OCI_Connection *con) |
Return the current date format for implicit string / date conversions. | |
OCI_EXPORT boolean OCI_API | OCI_SetDefaultFormatNumeric (OCI_Connection *con, const mtext *format) |
Set the numeric format for implicit string / numeric conversions. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetDefaultFormatNumeric (OCI_Connection *con) |
Return the current numeric format for implicit string / numeric conversions. | |
OCI_EXPORT OCI_Transaction *OCI_API | OCI_GetTransaction (OCI_Connection *con) |
Return the current transaction of the connection. | |
OCI_EXPORT boolean OCI_API | OCI_SetTransaction (OCI_Connection *con, OCI_Transaction *trans) |
Return the current transaction attached to the connection. | |
OCI_EXPORT unsigned int OCI_API | OCI_GetVersionConnection (OCI_Connection *con) |
Return the highest Oracle version is supported by the connection. | |
OCI_EXPORT boolean OCI_API | OCI_SetTrace (OCI_Connection *con, unsigned int trace, const mtext *value) |
Set tracing information to the session of the given connection. | |
OCI_EXPORT const mtext *OCI_API | OCI_GetTrace (OCI_Connection *con, unsigned int trace) |
Get the current trace for the trace type from the given connection. | |
OCI_EXPORT boolean OCI_API | OCI_Ping (OCI_Connection *con) |
Makes a round trip call to the server to confirm that the connection and the server are active. |
OCI_EXPORT OCI_Connection* OCI_API OCI_ConnectionCreate | ( | const mtext * | db, | |
const mtext * | user, | |||
const mtext * | pwd, | |||
unsigned int | mode | |||
) |
Create a physical connection to an Oracle database server.
db | - Oracle Service Name | |
user | - Oracle User name | |
pwd | - Oracle User password | |
mode | - Session mode |
Possible values for parameter mode :
Definition at line 750 of file connection.c.
References OCI_ConnectionFree().
Referenced by OCI_DatabaseShutdown(), and OCI_DatabaseStartup().
OCI_EXPORT boolean OCI_API OCI_ConnectionFree | ( | OCI_Connection * | con | ) |
Close a physical connection to an Oracle database server.
con | - Connection handle |
Definition at line 785 of file connection.c.
Referenced by OCI_ConnectionCreate(), OCI_DatabaseShutdown(), OCI_DatabaseStartup(), OCI_PoolGetConnection(), and OCI_SetUserPassword().
OCI_EXPORT boolean OCI_API OCI_IsConnected | ( | OCI_Connection * | con | ) |
Returns TRUE is the given connection is still connected otherwise FALSE.
con | - Connection handle |
Definition at line 912 of file connection.c.
OCI_EXPORT void* OCI_API OCI_GetUserData | ( | OCI_Connection * | con | ) |
Return the pointer to user data previously associated with the connection.
con | - Connection handle |
Definition at line 942 of file connection.c.
OCI_EXPORT boolean OCI_API OCI_SetUserData | ( | OCI_Connection * | con, | |
void * | data | |||
) |
Associate a pointer to user data to the given connection.
con | - Connection handle | |
data | - User data pointer |
Definition at line 958 of file connection.c.
OCI_EXPORT boolean OCI_API OCI_SetSessionTag | ( | OCI_Connection * | con, | |
const mtext * | tag | |||
) |
Associate a tag to the given connection/session.
con | - Connection handle | |
tag | - user tag string |
Definition at line 977 of file connection.c.
OCI_EXPORT const mtext* OCI_API OCI_GetSessionTag | ( | OCI_Connection * | con | ) |
Return the tag associated the the given connection.
con | - Connection handle |
Definition at line 1017 of file connection.c.
OCI_EXPORT const mtext* OCI_API OCI_GetDatabase | ( | OCI_Connection * | con | ) |
Return the name of the connected database/service name.
con | - Connection handle |
Definition at line 1033 of file connection.c.
OCI_EXPORT const mtext* OCI_API OCI_GetUserName | ( | OCI_Connection * | con | ) |
Return the current logged user name.
con | - Connection handle |
Definition at line 1049 of file connection.c.
OCI_EXPORT const mtext* OCI_API OCI_GetPassword | ( | OCI_Connection * | con | ) |
Return the current logged user password.
con | - Connection handle |
Definition at line 1065 of file connection.c.
OCI_EXPORT boolean OCI_API OCI_SetPassword | ( | OCI_Connection * | con, | |
const mtext * | password | |||
) |
Change the password of the logged user.
con | - Connection handle | |
password | - New password |
Definition at line 1081 of file connection.c.
OCI_EXPORT boolean OCI_API OCI_SetUserPassword | ( | const mtext * | db, | |
const mtext * | user, | |||
const mtext * | pwd, | |||
const mtext * | new_pwd | |||
) |
Change the password of the given user on the given database.
db | - Oracle Service Name | |
user | - Oracle User name | |
pwd | - Oracle User password | |
new_pwd | - Oracle User New password |
Definition at line 1120 of file connection.c.
References OCI_ConnectionFree().
OCI_EXPORT unsigned int OCI_API OCI_GetSessionMode | ( | OCI_Connection * | con | ) |
Return the current session mode.
con | - Connection handle |
Definition at line 1164 of file connection.c.
OCI_EXPORT const mtext* OCI_API OCI_GetVersionServer | ( | OCI_Connection * | con | ) |
Return the connected database server version.
con | - Connection handle |
Definition at line 1180 of file connection.c.
Referenced by OCI_GetServerMajorVersion(), OCI_GetServerMinorVersion(), and OCI_GetServerRevisionVersion().
OCI_EXPORT unsigned int OCI_API OCI_GetServerMajorVersion | ( | OCI_Connection * | con | ) |
Return the major version number of the connected database server.
con | - Connection handle |
Definition at line 1267 of file connection.c.
References OCI_GetVersionServer().
Referenced by OCI_GetVersionConnection().
OCI_EXPORT unsigned int OCI_API OCI_GetServerMinorVersion | ( | OCI_Connection * | con | ) |
Return the minor version number of the connected database server.
con | - Connection handle |
Definition at line 1286 of file connection.c.
References OCI_GetVersionServer().
OCI_EXPORT unsigned int OCI_API OCI_GetServerRevisionVersion | ( | OCI_Connection * | con | ) |
Return the revision version number of the connected database server.
con | - Connection handle |
Definition at line 1305 of file connection.c.
References OCI_GetVersionServer().
OCI_EXPORT boolean OCI_API OCI_SetDefaultFormatDate | ( | OCI_Connection * | con, | |
const mtext * | format | |||
) |
Set the date format for implicit string / date conversions.
con | - Connection handle | |
format | - Date format |
Definition at line 1388 of file connection.c.
Referenced by OCI_GetDefaultFormatDate().
OCI_EXPORT const mtext* OCI_API OCI_GetDefaultFormatDate | ( | OCI_Connection * | con | ) |
Return the current date format for implicit string / date conversions.
con | - Connection handle |
Definition at line 1413 of file connection.c.
References OCI_SetDefaultFormatDate().
Referenced by OCI_GetString().
OCI_EXPORT boolean OCI_API OCI_SetDefaultFormatNumeric | ( | OCI_Connection * | con, | |
const mtext * | format | |||
) |
Set the numeric format for implicit string / numeric conversions.
con | - Connection handle | |
format | - Numeric format |
Definition at line 1432 of file connection.c.
Referenced by OCI_GetDefaultFormatNumeric().
OCI_EXPORT const mtext* OCI_API OCI_GetDefaultFormatNumeric | ( | OCI_Connection * | con | ) |
Return the current numeric format for implicit string / numeric conversions.
con | - Connection handle |
Definition at line 1457 of file connection.c.
References OCI_SetDefaultFormatNumeric().
Referenced by OCI_GetString().
OCI_EXPORT OCI_Transaction* OCI_API OCI_GetTransaction | ( | OCI_Connection * | con | ) |
Return the current transaction of the connection.
con | - Connection handle |
Definition at line 1324 of file connection.c.
OCI_EXPORT boolean OCI_API OCI_SetTransaction | ( | OCI_Connection * | con, | |
OCI_Transaction * | trans | |||
) |
Return the current transaction attached to the connection.
con | - Connection handle | |
trans | - Transaction handle to assign |
Definition at line 1340 of file connection.c.
References OCI_TransactionStop().
OCI_EXPORT unsigned int OCI_API OCI_GetVersionConnection | ( | OCI_Connection * | con | ) |
Return the highest Oracle version is supported by the connection.
con | - connection handle |
Definition at line 1365 of file connection.c.
References OCI_GetOCIRuntimeVersion(), and OCI_GetServerMajorVersion().
Referenced by OCI_RegisterDate().
OCI_EXPORT boolean OCI_API OCI_SetTrace | ( | OCI_Connection * | con, | |
unsigned int | trace, | |||
const mtext * | value | |||
) |
Set tracing information to the session of the given connection.
con | - connection handle | |
trace | - trace type | |
value | - trace content |
Store current trace information to the given connection handle. These information:
Definition at line 1673 of file connection.c.
OCI_EXPORT const mtext* OCI_API OCI_GetTrace | ( | OCI_Connection * | con, | |
unsigned int | trace | |||
) |
Get the current trace for the trace type from the given connection.
con | - connection handle | |
trace | - trace type |
Definition at line 1808 of file connection.c.
OCI_EXPORT boolean OCI_API OCI_Ping | ( | OCI_Connection * | con | ) |
Makes a round trip call to the server to confirm that the connection and the server are active.
con | - Connection handle |
Definition at line 1858 of file connection.c.