Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) Part Number B14308-01 |
|
A database object represents an Oracle database. If more than one database is opened on a single session with the same database name and connect information (username and password), those database objects share a connection (see OConnection).
Use ODatabase to log on to an Oracle database. You can then execute SQL statements directly with the ExecuteSQL method or you can get records from the Oracle database by using the ODatabase object to create ODynaset objects (see ODynaset). ODatabase is a subclass of OOracleObject.
Four options are available for the ODatabase at the time it is opened. These options are ORed together on the Open method call. They affect operations on dynasets attached to this database. The options are:
Option |
Description |
---|---|
ODATABASE_ORAMODE | Turn on requerying on insert |
ODATABASE_EDIT_NOWAIT | Turn on no-waiting on StartEdit calls |
ODATABASE_NO_REFETCH | Let Oracle set default field (column) values as with ODATABASE_ORAMODE, but data is not refetched after the insert or update operation. |
ODATABASE_NONBLOCK | Turn on Non Blocking mode on sql statement execution. |
ODATABASE_DEFAULT | Accept the default behavior. |
By default these options are off.
ODATABASE_ORAMODE affects the way that AddNew, Edit, and Update put values into the Oracle database and how they change the values of the local data cache. (See ODynaset for a description of the local data cache.) The "partial insert" option of the database affects all dynasets that are created on the database.
If ODATABASE_ORAMODE is off (the default), dynasets behave the way they do in Visual Basic:
If ODATABASE_ORAMODE is on, dynasets will behave slightly differently:
If you are accessing tables that have default values for their fields, or that have triggers that set values on Insert or Update, then you will probably want to user the ODATABASE_ORAMODE option. This will cause the dynaset to refetch records after it makes changes to the data, ensuring that the dynaset and the database will always agree on the record's data. Please see StartEdit for more information.
ODATABASE_EDIT_NOWAIT affects what happens when ODynaset::StartEdit method is called. When StartEdit is called, the dynaset attempts to obtain a lock on the record that is being edited. (See "Locks and Editing"). It also affects ExecuteSQL when the SQL statement being executed performs inserts, updates, or deletes.
ODATABASE_NO_REFETCH is same as ODATABASE_ORAMODE for setting default values to the fields (columns) by Oracle. However, the data is not refetched to the local cache, boosting performance.
ODATABASE_NONBLOCK executes SQL statement in Non Blocking mode. This mode is not available under 32-bit platform.
The ODatabase class supports the following methods:
Construction and destruction:
Attributes:
operator==
operator!=
IsOpen
GetAutoCommit
GetConnectString
GetConnectionOK
GetName
GetOptions
SetAutoCommit
SetCacheMaximumSize
SetCacheOptimalSize
Operations:
BeginTrans
Close
CommitTrans
Describe
ExecuteSQL
GetConnection
GetParameters
GetRowsProcessed
GetSession
Open
RemoveFromPool
Rollback
Error Handling:
ErrorNumber
ErrorReset
GetErrorText
GetServerErrorText
LookupErrorText
ServerErrorNumber
ServerErrorReset
ServerErrorSQLPos