OCILIB (C Driver for Oracle) 3.12.1
Functions
Managing transactions

Detailed Description

OCILIB supports local and global transactions.

Local transactions are implicit within connection objects and there is no specific call or programming step for using it.

In order to control changes made in the database:

OCILIB supports a feature called 'Auto Commit' that performs an implicit and automatic commit call after every execute call

Note:
Those actions are executed within a connection context and not directly to a transaction.
Warning:
Global transactions are optional and are designed for distributed or global transaction environments.

OCILIB supports them by :

Note:
OCILIB does not yet suppport XA environments

Functions

OCI_EXPORT boolean OCI_API OCI_Commit (OCI_Connection *con)
 Commit current pending changes.
OCI_EXPORT boolean OCI_API OCI_Rollback (OCI_Connection *con)
 Cancel current pending changes.
OCI_EXPORT boolean OCI_API OCI_SetAutoCommit (OCI_Connection *con, boolean enable)
 Enable / disable auto commit mode.
OCI_EXPORT boolean OCI_API OCI_GetAutoCommit (OCI_Connection *con)
 Get current auto commit mode status.
OCI_EXPORT OCI_Transaction *OCI_API OCI_TransactionCreate (OCI_Connection *con, unsigned int timeout, unsigned int mode, OCI_XID *pxid)
 Create a new global transaction or a serializable/read-only local transaction.
OCI_EXPORT boolean OCI_API OCI_TransactionFree (OCI_Transaction *trans)
 Free current transaction.
OCI_EXPORT boolean OCI_API OCI_TransactionStart (OCI_Transaction *trans)
 Start global transaction.
OCI_EXPORT boolean OCI_API OCI_TransactionStop (OCI_Transaction *trans)
 Stop current global transaction.
OCI_EXPORT boolean OCI_API OCI_TransactionResume (OCI_Transaction *trans)
 Resume a stopped global transaction.
OCI_EXPORT boolean OCI_API OCI_TransactionPrepare (OCI_Transaction *trans)
 Prepare a global transaction validation.
OCI_EXPORT boolean OCI_API OCI_TransactionForget (OCI_Transaction *trans)
 Cancel the prepared global transaction validation.
OCI_EXPORT unsigned int OCI_API OCI_TransactionGetMode (OCI_Transaction *trans)
 Return global transaction mode.
OCI_EXPORT unsigned int OCI_API OCI_TransactionGetTimeout (OCI_Transaction *trans)
 Return global transaction Timeout.

Function Documentation

OCI_EXPORT boolean OCI_API OCI_Commit ( OCI_Connection con)

Commit current pending changes.

Parameters:
con- Connection handle
Returns:
TRUE on success otherwise FALSE

Definition at line 1038 of file connection.c.

Referenced by OCI_TransactionStop().

OCI_EXPORT boolean OCI_API OCI_Rollback ( OCI_Connection con)

Cancel current pending changes.

Parameters:
con- Connection handle
Returns:
TRUE on success otherwise FALSE

Definition at line 1063 of file connection.c.

Referenced by OCI_TransactionStop().

OCI_EXPORT boolean OCI_API OCI_SetAutoCommit ( OCI_Connection con,
boolean  enable 
)

Enable / disable auto commit mode.

The auto commit mode allows commit changes after every executed SQL order

Parameters:
con- Connection handle
enable- Enable (TRUE) or disable (FALSE)
Returns:
TRUE on success otherwise FALSE

Definition at line 1088 of file connection.c.

OCI_EXPORT boolean OCI_API OCI_GetAutoCommit ( OCI_Connection con)

Get current auto commit mode status.

Parameters:
con- Connection handle
Returns:
TRUE if auto commit mode is activated otherwise FALSE

Definition at line 1107 of file connection.c.

OCI_EXPORT OCI_Transaction* OCI_API OCI_TransactionCreate ( OCI_Connection con,
unsigned int  timeout,
unsigned int  mode,
OCI_XID pxid 
)

Create a new global transaction or a serializable/read-only local transaction.

Parameters:
con- Connection handle
timeout- Time that a transaction stays inactive after being stopped
mode- Connection mode
pxid- pointer to a global transaction identifier structure
Note:
The parameter 'mode' can be one of the following values :
  • Global transactions:
    • OCI_TRS_NEW : By default starts a new, tightly coupled and migratable branch.
    • OCI_TRS_TIGHT : explicitly specifies a tightly coupled branch
    • OCI_TRS_LOOSE : specifies a loosely coupled branch
  • Global and local transactions :
    • OCI_TRS_READONLY - start a read-only transaction
    • OCI_TRS_READWRITE - start a read-write transaction
    • OCI_TRS_SERIALIZABLE : start a serializable transaction
Note:
For local transaction:
  • pass a NULL value for pxid

Definition at line 46 of file transaction.c.

References OCI_TransactionFree().

OCI_EXPORT boolean OCI_API OCI_TransactionFree ( OCI_Transaction trans)

Free current transaction.

Parameters:
trans- Connection handle
Returns:
TRUE on success otherwise FALSE

Definition at line 153 of file transaction.c.

Referenced by OCI_DatabaseShutdown(), and OCI_TransactionCreate().

OCI_EXPORT boolean OCI_API OCI_TransactionStart ( OCI_Transaction trans)

Start global transaction.

Parameters:
trans- Connection handle
Returns:
TRUE on success otherwise FALSE

Definition at line 179 of file transaction.c.

OCI_EXPORT boolean OCI_API OCI_TransactionStop ( OCI_Transaction trans)

Stop current global transaction.

Parameters:
trans- Connection handle
Returns:
TRUE on success otherwise FALSE

Definition at line 205 of file transaction.c.

References OCI_Commit(), and OCI_Rollback().

Referenced by OCI_SetTransaction().

OCI_EXPORT boolean OCI_API OCI_TransactionResume ( OCI_Transaction trans)

Resume a stopped global transaction.

Parameters:
trans- Global transaction handle
Returns:
TRUE on success otherwise FALSE

Definition at line 246 of file transaction.c.

OCI_EXPORT boolean OCI_API OCI_TransactionPrepare ( OCI_Transaction trans)

Prepare a global transaction validation.

Parameters:
trans- Global transaction handle
Returns:
TRUE on success otherwise FALSE

Definition at line 272 of file transaction.c.

OCI_EXPORT boolean OCI_API OCI_TransactionForget ( OCI_Transaction trans)

Cancel the prepared global transaction validation.

Parameters:
trans- Global transaction handle
Returns:
TRUE on success otherwise FALSE

Definition at line 297 of file transaction.c.

OCI_EXPORT unsigned int OCI_API OCI_TransactionGetMode ( OCI_Transaction trans)

Return global transaction mode.

Note:
: see OCI_TransactionCreate() for possible values
Parameters:
trans- Global transaction handle
Returns:
Transaction mode or OCI_UNKNOW if trans is NULL

Definition at line 322 of file transaction.c.

OCI_EXPORT unsigned int OCI_API OCI_TransactionGetTimeout ( OCI_Transaction trans)

Return global transaction Timeout.

Parameters:
trans- Global transaction handle
Returns:
Transaction timeout or 0 if trans is NULL

Definition at line 338 of file transaction.c.