class RSqlDatabase |
A handle to a SQL database.
create a SQL database by calling RSqlDatabase::Create().
open an existing SQL database by calling RSqlDatabase::Open().
close a SQL database by calling RSqlDatabase::Close().
copy a SQL database by calling RSqlDatabase::Copy().
delete a SQL database by calling RSqlDatabase::Delete().
attach a SQL database to current database connection by calling RSqlDatabase::Attach().
detach a SQL database from current database connection by calling RSqlDatabase::Detach().
The RSqlDatabase handles are not thread-safe.
a non-secure database is created if the RSqlDatabase::Create(const TDesC&) variant is used.
a secure database is created if the RSqlDatabase::Create(const TDesC&, const RSqlSecurityPolicy&) variant is used. In this case, a container containing a collection of security policies needs to be set up first and passed to this Create() function. See references to RSqlSecurityPolicy for more information on security policies.
A client can also specify how it wants a transaction to interact with other transactions that may be running concurrently. The various ways in which transactions can interact (i.e. how one transaction can affect another) are referred to as "transaction isolation levels", and are defined by the values of the TIsolationLevel enum. A client specifies this by calling RSqlDatabase::SetIsolationLevel().
Each of the various flavours of Open and Create allows the optional provision of a configuration string. It is acceptable for this string to be missing. In the case where the string is missing, the config in the SqlServer.sql file will be used. If that does not exist then the MMH macro definitions will be used.
The config string is in the format PARAM=VALUE; PARAM=VALUE;...
Allowed parameters are: cache_size=nnnn page_size=nnnn encoding=UTF8|UTF16
Badly formed config strings are reported as KErrArgument
The string may not exceed 255 characters.
Please note that a database can only be accessed within the thread where it has been created. It is then not possible to create a database from thread1 and access it from thread2.
A client calls RSqlDatabase::Exec() to execute SQL statements. RSqlDatabase::Create()
Public Member Functions | |
---|---|
RSqlDatabase() | |
IMPORT_C TInt | Attach(const TDesC &, const TDesC &) |
IMPORT_C void | Close() |
IMPORT_C TInt | Compact(TInt64, const TDesC &) |
IMPORT_C void | Compact(TInt64, TRequestStatus &, const TDesC &) |
IMPORT_C TInt | Copy(const TDesC &, const TDesC &) |
IMPORT_C TInt | Create(const TDesC &, const TDesC8 *) |
IMPORT_C TInt | Create(const TDesC &, const RSqlSecurityPolicy &, const TDesC8 *) |
IMPORT_C void | CreateL(const TDesC &, const TDesC8 *) |
IMPORT_C void | CreateL(const TDesC &, const RSqlSecurityPolicy &, const TDesC8 *) |
IMPORT_C TInt | Delete(const TDesC &) |
IMPORT_C TInt | Detach(const TDesC &) |
IMPORT_C TInt | Exec(const TDesC &) |
IMPORT_C TInt | Exec(const TDesC8 &) |
IMPORT_C void | Exec(const TDesC &, TRequestStatus &) |
IMPORT_C void | Exec(const TDesC8 &, TRequestStatus &) |
IMPORT_C void | FreeReservedSpace() |
IMPORT_C TInt | GetReserveAccess() |
IMPORT_C TInt | GetSecurityPolicy(RSqlSecurityPolicy &) |
IMPORT_C void | GetSecurityPolicyL(RSqlSecurityPolicy &) |
IMPORT_C TBool | InTransaction() |
IMPORT_C TPtrC | LastErrorMessage() |
IMPORT_C TInt64 | LastInsertedRowId() |
IMPORT_C TInt | Open(const TDesC &, const TDesC8 *) |
IMPORT_C void | OpenL(const TDesC &, const TDesC8 *) |
IMPORT_C void | ReleaseReserveAccess() |
IMPORT_C TInt | ReserveDriveSpace(TInt) |
IMPORT_C TInt | SetIsolationLevel(TIsolationLevel) |
IMPORT_C TInt | Size() |
IMPORT_C TInt | Size(TSize &, const TDesC &) |
Private Member Functions | |
---|---|
CSqlDatabaseImpl & | Impl() |
Public Member Enumerations | |
---|---|
enum | TIsolationLevel { EReadUncommitted, EReadCommitted, ERepeatableRead, ESerializable } |
Private Attributes | |
---|---|
CSqlDatabaseImpl * | iImpl |
IMPORT_C TInt | Attach | ( | const TDesC & | aDbFileName, |
const TDesC & | aDbName | |||
) |
IMPORT_C void | Compact | ( | TInt64 | aSize, |
TRequestStatus & | aStatus, | |||
const TDesC & | aDbName = KNullDesC | |||
) |
TInt64 aSize | |
TRequestStatus & aStatus | |
const TDesC & aDbName = KNullDesC |
IMPORT_C TInt | Copy | ( | const TDesC & | aSrcDbFileName, |
const TDesC & | aDestDbFileName | |||
) | [static] |
IMPORT_C TInt | Create | ( | const TDesC & | aDbFileName, |
const TDesC8 * | aConfig = NULL | |||
) |
IMPORT_C TInt | Create | ( | const TDesC & | aDbFileName, |
const RSqlSecurityPolicy & | aSecurityPolicy, | |||
const TDesC8 * | aConfig = NULL | |||
) |
const TDesC & aDbFileName | |
const RSqlSecurityPolicy & aSecurityPolicy | |
const TDesC8 * aConfig = NULL |
IMPORT_C void | CreateL | ( | const TDesC & | aDbFileName, |
const TDesC8 * | aConfig = NULL | |||
) |
IMPORT_C void | CreateL | ( | const TDesC & | aDbFileName, |
const RSqlSecurityPolicy & | aSecurityPolicy, | |||
const TDesC8 * | aConfig = NULL | |||
) |
const TDesC & aDbFileName | |
const RSqlSecurityPolicy & aSecurityPolicy | |
const TDesC8 * aConfig = NULL |
IMPORT_C TInt | Delete | ( | const TDesC & | aDbFileName | ) | [static] |
const TDesC & aDbFileName |
IMPORT_C void | Exec | ( | const TDesC & | aSqlStmt, |
TRequestStatus & | aStatus | |||
) |
const TDesC & aSqlStmt | |
TRequestStatus & aStatus |
IMPORT_C void | Exec | ( | const TDesC8 & | aSqlStmt, |
TRequestStatus & | aStatus | |||
) |
const TDesC8 & aSqlStmt | |
TRequestStatus & aStatus |
IMPORT_C TInt | GetSecurityPolicy | ( | RSqlSecurityPolicy & | aSecurityPolicy | ) | const |
RSqlSecurityPolicy & aSecurityPolicy |
IMPORT_C void | GetSecurityPolicyL | ( | RSqlSecurityPolicy & | aSecurityPolicy | ) | const |
RSqlSecurityPolicy & aSecurityPolicy |
IMPORT_C TInt | Open | ( | const TDesC & | aDbFileName, |
const TDesC8 * | aConfig = NULL | |||
) |
IMPORT_C void | OpenL | ( | const TDesC & | aDbFileName, |
const TDesC8 * | aConfig = NULL | |||
) |
IMPORT_C TInt | SetIsolationLevel | ( | TIsolationLevel | aIsolationLevel | ) |
TIsolationLevel aIsolationLevel |
IMPORT_C TInt | Size | ( | TSize & | aSize, |
const TDesC & | aDbName = KNullDesC | |||
) | const |
Defines a set of values that represents the transaction isolation level.
A transaction isolation level defines the way in which a transaction interacts with other transactions that may be in progress concurrently.
A client sets the transaction isolation level by calling SetIsolationLevel()
EReadUncommitted |
A transaction can read uncommitted data, i.e. data that is being changed by another transaction, which is still in progress. This means that
This transaction isolation level can be set at any time during the lifetime of the database. |
EReadCommitted |
Not currently supported. A transaction cannot read uncommitted data. "Dirty reads" are prevented. "Dirty read" is a data inconsistency type which can be described with the following example:
|
ERepeatableRead |
Not currently supported. A transaction cannot change data that is being read by a different transaction. "Dirty reads" and "non-repeatable reads" are prevented. "Non-repeatable reads" is a data inconsistency type which can be described with the following example:
|
ESerializable |
Any number of 'database read' transactions can be performed concurrently by different database connections on the same shared database. Only one 'database write' transaction can be performed at any one time. If a 'database write' transaction is in progress, then any attempt to start another 'database read' or 'database write' transaction will be blocked until the first 'database write' transaction has completed. This is the default isolation level, if no isolation level is explicitly set. "Dirty reads", "non-repeatable" reads and "phantom reads" are prevented. "Phantom reads" is a data inconsistency type which can be described with the following example:
|