1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // SQL Client side API header
27 #include <s32std.h> //RReadStream, RWriteStream
30 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
31 #include <sqlresourcetester.h>
34 //Forward declarations
35 class CSqlSecurityPolicy;
37 class CSqlDatabaseImpl;
39 class CSqlStatementImpl;
40 class RSqlColumnReadStream;
41 class RSqlParamWriteStream;
42 class TSqlScalarFullSelectQuery;
44 class RSqlBlobReadStream;
45 class RSqlBlobWriteStream;
46 class TSqlResourceProfiler;
49 Used to specify that the ROWID of the most recently inserted record
50 from the specified database connection should be used as the ROWID
51 in a call to directly access a blob.
53 @see RSqlBlobReadStream
54 @see RSqlBlobWriteStream
60 const TInt KSqlLastInsertedRowId = -1;
63 A container for the security policies for a shared SQL database.
65 The container can contain:
66 - security policies that apply to the database.
67 - security policies that apply to individual database objects, i.e. database tables.
69 For the database, you use RSqlSecurityPolicy::SetDbPolicy() to apply a separate
71 - the database schema.
72 - read activity on the database.
73 - write activity on the database.
75 For database tables, you use RSqlSecurityPolicy::SetPolicy() to apply a separate
77 - write activity on each named database table.
78 - read activity on each named database table.
80 A client uses a RSqlSecurityPolicy object to create a secure database. It does this by:
81 - creating a RSqlSecurityPolicy object.
82 - setting all the appropriate security policies into it.
83 - passing the object as an argument to RSqlDatabase::Create().
84 - closing the RSqlSecurityPolicy object on return from RSqlDatabase::Create().
86 Once a secure shared database has been created with specific security policies,
87 these policies are made persistent and cannot be changed during the life of
90 Security policies are encapsulated by TSecurityPolicy objects.
91 The general usage pattern is to create the security policies container object
92 (RSqlSecurityPolicy) using a default security policy (TSecurityPolicy), and then
93 to assign more specific 'overriding' security policies.
95 The following code fragment shows how you do this:
98 TSecurityPolicy defaultPolicy;
99 RSqlSecurityPolicy securityPolicy;
100 RSqlDatabase database;
103 // Create security policies container object using a default security policy.
104 securityPolicy.Create(defaultPolicy);
106 // Set up policy to apply to database schema
108 TSecurityPolicy schemaPolicy;
110 err = securityPolicy.SetDbPolicy(RSqlSecurityPolicy::ESchemaPolicy, schemaPolicy);
112 // Set up policy to apply to write activity on the database
114 TSecurityPolicy writePolicy;
116 err = securityPolicy.SetDbPolicy(RSqlSecurityPolicy::EWritePolicy, writePolicy);
118 // Set up policy to apply to write activity to the database table named "Table1"
120 TSecurityPolicy tablePolicy1;
122 err = securityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, _L("Table1"), RSqlSecurityPolicy::EWritePolicy, tablePolicy1);
124 // Set up policy to apply to read activity to the database table named "Table2"
125 TSecurityPolicy tablePolicy2;
126 err = securityPolicy.SetPolicy(RSqlSecurityPolicy::ETable, _L("Table2"), RSqlSecurityPolicy::EReadPolicy, tablePolicy2);
128 // Create the database, passing the security policies
129 err = database.Create(KDatabaseName, securityPolicy);
131 // We can close the RSqlSecurityPolicy object.
132 securityPolicy.Close();
135 Note that in this example code fragment, the client has not assigned specific
136 overriding policies for all possible cases; for example, no overriding policy
137 has been assigned to control read activity on the database, read activity
138 on "Table1", nor write activity on "Table2".
139 For these cases, the default security policy will apply.
141 A client can also retrieve a database's security policies by calling
142 RSqlDatabase::GetSecurityPolicy(); this returns a RSqlSecurityPolicy object
143 containing the security policies. Note that it is the client's responsibility
144 to close the RSqlSecurityPolicy object when the client no longer needs it. The
145 following code fragment suggests how you might do this:
148 RSqlDatabase database;
149 RSqlSecurityPolicy securityPolicy;
151 // Retrieve the security policies; on return from the call to
152 // GetSecurityPolicy(), the RSqlSecurityPolicy object passed
153 // to this function will contain the security policies.
154 database.GetSecurityPolicy(securityPolicy);
156 // This is the security policy that applies to database schema
157 TSecurityPolicy schemaPolicy = securityPolicy.DbPolicy(RSqlSecurityPolicy::ESchemaPolicy);
159 // This is the security policy that applies to write activity to the database
160 // table named "Table1".
161 TSecurityPolicy writePolicy = securityPolicy.Policy(RSqlSecurityPolicy::ETable, _L("Table1"), RSqlSecurityPolicy::EWritePolicy);
163 // Close the RSqlSecurityPolicy object when no longer needed.
164 securityPolicy.Close();
167 Note that in the cases where an 'overriding' security policy was not originally assigned,
168 then the security policy returned will simply be the default security policy.
172 @see RSqlSecurityPolicy::SetDbPolicy()
173 @see RSqlSecurityPolicy::SetPolicy()
178 class RSqlSecurityPolicy
180 friend class RSqlDatabase;
184 Defines a set of values that represents the database security policy types.
185 Each database security policy type refers to a set of capabilities encapsulated in
186 a TSecurityPolicy object. The TSecurityPolicy object defines what capabilities the calling
187 application must have in order to perform partiqular database operation.
193 Schema database security policy. An application with schema database security policy can
194 modify the database schema, write to database, read from database.
198 Read database security policy. An application with read database security policy can
203 Write database security policy. An application with write database security policy can
209 Not currently supported.
211 Defines a set of values that represents the database objects which can be protected by
212 database security policy types.
218 IMPORT_C RSqlSecurityPolicy();
219 IMPORT_C TInt Create(const TSecurityPolicy& aDefaultPolicy);
220 IMPORT_C void CreateL(const TSecurityPolicy& aDefaultPolicy);
221 IMPORT_C void Close();
222 IMPORT_C TInt SetDbPolicy(TPolicyType aPolicyType, const TSecurityPolicy& aPolicy);
223 IMPORT_C TInt SetPolicy(TObjectType aObjectType, const TDesC& aObjectName, TPolicyType aPolicyType, const TSecurityPolicy& aPolicy);
224 IMPORT_C TSecurityPolicy DefaultPolicy() const;
225 IMPORT_C TSecurityPolicy DbPolicy(TPolicyType aPolicyType) const;
226 IMPORT_C TSecurityPolicy Policy(TObjectType aObjectType, const TDesC& aObjectName, TPolicyType aPolicyType) const;
228 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
229 IMPORT_C void InternalizeL(RReadStream& aStream);
232 void Set(CSqlSecurityPolicy& aImpl);
233 CSqlSecurityPolicy& Impl() const;
236 CSqlSecurityPolicy* iImpl;
240 A handle to a SQL database.
242 A RSqlDatabase object is, in effect, a handle to the SQL database. A client can:
243 - create a SQL database by calling RSqlDatabase::Create().
244 - open an existing SQL database by calling RSqlDatabase::Open().
245 - close a SQL database by calling RSqlDatabase::Close().
246 - copy a SQL database by calling RSqlDatabase::Copy().
247 - delete a SQL database by calling RSqlDatabase::Delete().
248 - attach a SQL database to current database connection by calling RSqlDatabase::Attach().
249 - detach a SQL database from current database connection by calling RSqlDatabase::Detach().
251 The RSqlDatabase handles are not thread-safe.
253 A client can create either a non-secure database or a secure database,
254 depending on the variant of RSqlDatabase::Create() that is used.
255 - a non-secure database is created if the RSqlDatabase::Create(const TDesC&) variant is used.
256 - a secure database is created if the RSqlDatabase::Create(const TDesC&, const RSqlSecurityPolicy&)
257 variant is used. In this case, a container containing a collection of security
258 policies needs to be set up first and passed to this Create() function.
259 See references to RSqlSecurityPolicy for more information on security policies.
261 A client can also specify how it wants a transaction to interact with
262 other transactions that may be running concurrently. The various ways in which
263 transactions can interact (i.e. how one transaction can affect another) are
264 referred to as "transaction isolation levels", and are defined by the values
265 of the TIsolationLevel enum. A client specifies this by calling RSqlDatabase::SetIsolationLevel().
267 Each of the various flavours of Open and Create allows the optional provision of a
268 configuration string. It is acceptable for this string to be missing.
269 In the case where the string is missing, the config in the SqlServer.sql file
270 will be used. If that does not exist then the MMH macro definitions will be used.
272 The config string is in the format PARAM=VALUE; PARAM=VALUE;...
274 Allowed parameters are:
279 Badly formed config strings are reported as KErrArgument
281 The string may not exceed 255 characters.
283 Please note that a database can only be accessed within the thread where it has been created. It is then not possible
284 to create a database from thread1 and access it from thread2.
286 A client calls RSqlDatabase::Exec() to execute SQL statements.
287 @see RSqlDatabase::Create()
288 @see RSqlDatabase::Open()
289 @see RSqlDatabase::Close()
290 @see RSqlDatabase::Copy()
291 @see RSqlDatabase::Delete()
292 @see RSqlDatabase::Attach()
293 @see RSqlDatabase::Detach()
294 @see RSqlDatabase::SetIsolationLevel()
295 @see RSqlDatabase::Exec()
297 @see RSqlSecurityPolicy
304 friend class RSqlStatement;
305 friend class TSqlScalarFullSelectQuery;
306 friend class RSqlBlob;
307 friend class RSqlBlobReadStream;
308 friend class RSqlBlobWriteStream;
309 friend class TSqlResourceProfiler;
313 Defines a set of values that represents the transaction isolation level.
315 A transaction isolation level defines the way in which a transaction
316 interacts with other transactions that may be in progress concurrently.
318 A client sets the transaction isolation level by calling SetIsolationLevel()
320 @see RSqlDatabase::SetIsolationLevel()
325 A transaction can read uncommitted data, i.e. data that is being changed
326 by another transaction, which is still in progress.
329 - a 'database read' transaction will not block 'database write' transactions
330 being performed by different database connections on the same shared database.
331 - a 'database read' transaction will not be blocked by 'database write'
332 transactions performed by the same database connection.
333 - concurrent 'database write' transactions are prevented.
335 This transaction isolation level can be set at any time during
336 the lifetime of the database.
339 @see RSqlDatabase::SetIsolationLevel()
344 Not currently supported.
346 A transaction cannot read uncommitted data. "Dirty reads" are prevented.
348 "Dirty read" is a data inconsistency type which can be described with the following example:
349 - Transaction A updates TableA.Column1 value from 1 to 2;
350 - Transaction B reads TableA.Column1 value;
351 - Transaction A rolls back and restores the original value of TableA.Column1 (1);
352 - Transaction B ends showing that TableA.Column1 value is 2, even though, logically and transactionally,
353 this data never really even existed in the database because Transaction A never committed that change
357 @see RSqlDatabase::SetIsolationLevel()
362 Not currently supported.
364 A transaction cannot change data that is being read by a different transaction.
365 "Dirty reads" and "non-repeatable reads" are prevented.
367 "Non-repeatable reads" is a data inconsistency type which can be described with the following example:
368 - Transaction A reads TableA.Column1 value which is 1;
369 - Transaction B updates TableA.Column1 value from 1 to 2;
370 - Transaction B commits the chages;
371 - Transaction A reads TableA.Column1 value again. Transaction A has inconsistent data because TableA.Column1
372 value now is 2 instead of 1, all within the scope of the same Transaction A;
375 @see RSqlDatabase::SetIsolationLevel()
380 Any number of 'database read' transactions can be performed concurrently
381 by different database connections on the same shared database.
383 Only one 'database write' transaction can be performed at any one time. If a
384 'database write' transaction is in progress, then any attempt to start
385 another 'database read' or 'database write' transaction will be blocked
386 until the first 'database write' transaction has completed.
388 This is the default isolation level, if no isolation level is
391 "Dirty reads", "non-repeatable" reads and "phantom reads" are prevented.
393 "Phantom reads" is a data inconsistency type which can be described with the following example:
394 - Transaction A reads all rows that have Column1 = 1;
395 - Transaction B inserts a new row which has Column1 = 1;
396 - Transaction B commits;
397 - Transaction A updates all rows that have Column1 = 1. This will also update the row that
398 Transaction B inserted, because Transaction A must read the data again in order to update it.
399 - Transaction A commits;
402 @see RSqlDatabase::SetIsolationLevel()
407 This structure is used for retrieving the database size and database free space.
408 @see RSqlDatabase::Size(TSize&)
412 /** The database size in bytes*/
414 /** The database free space in bytes*/
418 /** If this value is used as an argument of RSqlDatabase::Compact() (aSize argument), then all free space will be removed */
419 enum {EMaxCompaction = -1};
421 IMPORT_C RSqlDatabase();
423 IMPORT_C TInt Create(const TDesC& aDbFileName, const TDesC8* aConfig=NULL);
424 IMPORT_C TInt Create(const TDesC& aDbFileName,
425 const RSqlSecurityPolicy& aSecurityPolicy, const TDesC8* aConfig=NULL);
426 IMPORT_C TInt Open(const TDesC& aDbFileName, const TDesC8* aConfig=NULL);
427 IMPORT_C void CreateL(const TDesC& aDbFileName, const TDesC8* aConfig=NULL);
428 IMPORT_C void CreateL(const TDesC& aDbFileName,
429 const RSqlSecurityPolicy& aSecurityPolicy, const TDesC8* aConfig=NULL);
430 IMPORT_C void OpenL(const TDesC& aDbFileName, const TDesC8* aConfig=NULL);
432 IMPORT_C void Close();
434 IMPORT_C TInt Attach(const TDesC& aDbFileName, const TDesC& aDbName);
435 IMPORT_C TInt Detach(const TDesC& aDbName);
437 IMPORT_C static TInt Copy(const TDesC& aSrcDbFileName, const TDesC& aDestDbFileName);
438 IMPORT_C static TInt Delete(const TDesC& aDbFileName);
440 IMPORT_C TInt GetSecurityPolicy(RSqlSecurityPolicy& aSecurityPolicy) const;
441 IMPORT_C void GetSecurityPolicyL(RSqlSecurityPolicy& aSecurityPolicy) const;
443 IMPORT_C TInt SetIsolationLevel(TIsolationLevel aIsolationLevel);
445 IMPORT_C TInt Exec(const TDesC& aSqlStmt);
446 IMPORT_C TInt Exec(const TDesC8& aSqlStmt);
448 IMPORT_C void Exec(const TDesC& aSqlStmt, TRequestStatus& aStatus);
449 IMPORT_C void Exec(const TDesC8& aSqlStmt, TRequestStatus& aStatus);
451 IMPORT_C TPtrC LastErrorMessage() const;
452 IMPORT_C TInt64 LastInsertedRowId() const;
454 IMPORT_C TBool InTransaction() const;
455 IMPORT_C TInt Size() const;
456 IMPORT_C TInt Size(TSize& aSize, const TDesC& aDbName = KNullDesC) const;
458 IMPORT_C TInt Compact(TInt64 aSize, const TDesC& aDbName = KNullDesC);
459 IMPORT_C void Compact(TInt64 aSize, TRequestStatus& aStatus, const TDesC& aDbName = KNullDesC);
461 IMPORT_C TInt ReserveDriveSpace(TInt aSize);
462 IMPORT_C void FreeReservedSpace();
463 IMPORT_C TInt GetReserveAccess();
464 IMPORT_C void ReleaseReserveAccess();
467 CSqlDatabaseImpl& Impl() const;
470 CSqlDatabaseImpl* iImpl;
474 TSqlScalarFullSelectQuery interface is used for executing SELECT sql queries, which
475 return a single row consisting of a single column value.
479 CASE 1 - retrieving records count of a table:
482 //initialize db object....
484 TSqlScalarFullSelectQuery fullSelectQuery(db);
485 TInt recCnt = fullSelectQuery.SelectIntL(_L("SELECT COUNT(*) FROM PersonTbl"));
488 CASE 2 - retrieving specific column value using a condition in the SELECT statement:
491 //initialize db object....
493 TSqlScalarFullSelectQuery fullSelectQuery(db);
494 TInt personId = fullSelectQuery.SelectIntL(_L("SELECT ID FROM PersonTbl WHERE Name = 'John'"));
497 CASE 3 - retrieving a text column value, the receiving buffer is not big enough:
500 //initialize db object....
502 TSqlScalarFullSelectQuery fullSelectQuery(db);
503 HBufC* buf = HBufC::NewLC(20);
504 TPtr name = buf->Des();
505 TInt rc = fullSelectQuery.SelectTextL(_L("SELECT Name FROM PersonTbl WHERE Id = 1"), name);
506 TEST(rc >= 0); //the function may return only non-negative values
509 buf = buf->ReAllocL(rc);
511 CleanupStack::PushL(buf);
512 name.Set(buf->Des());
513 rc = fullSelectQuery.SelectTextL(_L("SELECT Name FROM PersonTbl WHERE Id = 1"), name);
516 CleanupStack::PopAndDestroy();//buf
524 class TSqlScalarFullSelectQuery
527 IMPORT_C TSqlScalarFullSelectQuery();
528 IMPORT_C TSqlScalarFullSelectQuery(RSqlDatabase& aDatabase);
529 IMPORT_C void SetDatabase(RSqlDatabase& aDatabase);
531 IMPORT_C TInt SelectIntL(const TDesC& aSqlStmt);
532 IMPORT_C TInt64 SelectInt64L(const TDesC& aSqlStmt);
533 IMPORT_C TReal SelectRealL(const TDesC& aSqlStmt);
534 IMPORT_C TInt SelectTextL(const TDesC& aSqlStmt, TDes& aDest);
535 IMPORT_C TInt SelectBinaryL(const TDesC& aSqlStmt, TDes8& aDest);
537 IMPORT_C TInt SelectIntL(const TDesC8& aSqlStmt);
538 IMPORT_C TInt64 SelectInt64L(const TDesC8& aSqlStmt);
539 IMPORT_C TReal SelectRealL(const TDesC8& aSqlStmt);
540 IMPORT_C TInt SelectTextL(const TDesC8& aSqlStmt, TDes& aDest);
541 IMPORT_C TInt SelectBinaryL(const TDesC8& aSqlStmt, TDes8& aDest);
544 inline CSqlDatabaseImpl& Impl() const;
547 CSqlDatabaseImpl* iDatabaseImpl;
551 An enumeration whose values represent the supported database column types.
554 @see RSqlStatement::ColumnType()
567 32-bit integer column value.
572 64-bit integer column value.
577 64-bit floating point column value.
582 Unicode text, a sequence of 16-bit character codes.
587 Binary data, a sequence of bytes.
593 Represents an SQL statement.
595 An object of this type can be used to execute all types of SQL statements; this
596 includes SQL statements with parameters.
598 If a SELECT statament is passed to RSqlStatement::Prepare(), then the returned record set
599 is forward only, non-updateable.
601 There are a number of ways that this object is used; here are some examples.
603 CASE 1 - the execution of a SQL statement, which does not return record set:
606 RSqlDatabase database;
609 TInt err = stmt.Prepare(database, _L("INSERT INTO Tbl1(Fld1) VALUES(:Val)"));
610 TInt paramIndex = stmt.ParameterIndex(_L(":Val"));
611 for(TInt i=1;i<=10;++i)
613 err = stmt.BindInt(paramIndex, i);
620 The following pseudo code shows the general pattern:
623 <RSqlStatement::Prepare()>
625 <RSqlStatement::Bind<param_type>()>
626 <RSqlStatement::Exec()>
627 [<RSqlStatement::Reset()>]
628 [<RSqlStatement::Bind<param_type>()>]
632 CASE 2 - the execution of a SQL statement, which returns a record set:
635 RSqlDatabase database;
638 TInt err = stmt.Prepare(database, _L("SELECT Fld1 FROM Tbl1 WHERE Fld1 > :Val"));
639 TInt paramIndex = stmt.ParameterIndex(_L(":Val"));
640 err = stmt.BindInt(paramIndex, 5);
641 TInt columnIndex = stmt.ColumnIndex(_L("Fld1"));
642 while((err = stmt.Next()) == KSqlAtRow)
644 TInt val = stmt.ColumnInt(columnIndex);
645 RDebug::Print(_L("val=%d\n"), val);
648 <OK - no more records>;
654 The following pseudo code shows the general pattern:
657 <RSqlStatement::Prepare()>
659 <while (RSqlStatement::Next() == KSqlAtRow)>
660 <do something with the records>
662 <OK - no more records>;
665 [<RSqlStatement::Reset()>]
666 [<RSqlStatement::Bind<param_type>()>]
670 CASE 3.1 - SELECT statements: large column data processing, where the data is
671 copied into a buffer supplied by the client:
674 RSqlDatabase database;
677 TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
678 TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
679 while((err = stmt.Next()) == KSqlAtRow)
681 TInt size = stmt. ColumnSize(columnIndex);
682 HBufC8* buf = HBufC8::NewL(size);
683 err = stmt.ColumnBinary(columnIndex, buf->Ptr());
684 <do something with the data>;
688 <OK - no more records>;
694 CASE 3.2 - SELECT statements: large column data processing, where the data is
695 accessed by the client without copying:
698 RSqlDatabase database;
701 TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
702 TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
703 while((err = stmt.Next()) == KSqlAtRow)
705 TPtrC8 data = stmt.ColumnBinaryL(columnIndex);
706 <do something with the data>;
709 <OK - no more records>;
715 CASE 3.3 - SELECT statements, large column data processing (the data is accessed by
716 the client without copying), leaving-safe processing:
719 RSqlDatabase database;
722 TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
723 TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
724 while((err = stmt.Next()) == KSqlAtRow)
727 TInt err = stmt.ColumnBinary(columnIndex, data);
730 <do something with the data>;
734 <OK - no more records>;
740 CASE 3.4 - SELECT statements: large column data processing, where the data is
741 accessed by the client using a stream:
744 RSqlDatabase database;
747 TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
748 TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
749 while((err = stmt.Next()) == KSqlAtRow)
751 RSqlColumnReadStream stream;
752 err = stream.ColumnBinary(stmt, columnIndex);
753 <do something with the data in the stream>;
757 <OK - no more records>;
763 CASE 4 - the execution of a SQL statement with parameter(s), some of which may
764 be large text or binary values:
767 RSqlDatabase database;
771 stmt.Prepare(database, _L("UPDATE Tbl1 SET LargeTextField = :LargeTextVal WHERE IdxField = :KeyVal"));
772 TInt paramIndex1 = stmt.ParameterIndex(_L(":LargeTextVal"));
773 TInt paramIndex2 = stmt.ParameterIndex(_L(":KeyVal"));
774 for(TInt i=1;i<=10;++i)
776 RSqlParamWriteStream stream;
777 err = stream.BindText(stmt, paramIndex1);
778 <insert large text data into the stream>;
780 err = stmt.BindInt(paramIndex2, i);
787 The following table shows what is returned when the caller uses a specific
788 column data retrieving function on a specific column type.
791 --------------------------------------------------------------------------------
792 Column type | ColumnInt() ColumnInt64() ColumnReal() ColumnText() ColumnBinary()
793 --------------------------------------------------------------------------------
794 Null........|.0...........0.............0.0..........KNullDesC....KNullDesC8
795 Int.........|.Int.........Int64.........Real.........KNullDesC....KNullDesC8
796 Int64.......|.clamp.......Int64.........Real.........KNullDesC....KNullDesC8
797 Real........|.round.......round.........Real.........KNullDesC....KNullDesC8
798 Text........|.0...........0.............0.0..........Text.........KNullDesC8
799 Binary......|.0...........0.............0.0..........KNullDesC....Binary
800 --------------------------------------------------------------------------------
802 Note the following definitions:
803 - "clamp": return KMinTInt or KMaxTInt if the value is outside the range that can be
804 represented by the type returned by the accessor function.
805 - "round": the floating point value will be rounded up to the nearest integer.
806 If the result is outside the range that can be represented by the type returned
807 by the accessor function, then it will be clamped.
809 Note that when handling blob and text data over 2Mb in size it is recommended that the
810 RSqlBlobReadStream and RSqlBlobWriteStream classes or the TSqlBlob class is used instead.
811 These classes provide a more RAM-efficient way of reading and writing large amounts of
812 blob or text data from a database.
818 @see RSqlBlobReadStream
819 @see RSqlBlobWriteStream
827 friend class RSqlColumnReadStream;
828 friend class RSqlParamWriteStream;
831 IMPORT_C RSqlStatement();
832 IMPORT_C TInt Prepare(RSqlDatabase& aDatabase, const TDesC& aSqlStmt);
833 IMPORT_C TInt Prepare(RSqlDatabase& aDatabase, const TDesC8& aSqlStmt);
834 IMPORT_C void PrepareL(RSqlDatabase& aDatabase, const TDesC& aSqlStmt);
835 IMPORT_C void PrepareL(RSqlDatabase& aDatabase, const TDesC8& aSqlStmt);
836 IMPORT_C void Close();
837 IMPORT_C TBool AtRow() const;
838 IMPORT_C TInt Reset();
839 IMPORT_C TInt Exec();
840 IMPORT_C void Exec(TRequestStatus& aStatus);
841 IMPORT_C TInt Next();
843 IMPORT_C TInt ParameterIndex(const TDesC& aParameterName) const;
844 IMPORT_C TInt ColumnCount() const;
845 IMPORT_C TInt ColumnIndex(const TDesC& aColumnName) const;
846 IMPORT_C TSqlColumnType ColumnType(TInt aColumnIndex) const;
847 IMPORT_C TInt DeclaredColumnType(TInt aColumnIndex, TSqlColumnType& aColumnType) const;
848 IMPORT_C TInt ColumnSize(TInt aColumnIndex) const;
850 IMPORT_C TInt BindNull(TInt aParameterIndex);
851 IMPORT_C TInt BindInt(TInt aParameterIndex, TInt aParameterValue);
852 IMPORT_C TInt BindInt64(TInt aParameterIndex, TInt64 aParameterValue);
853 IMPORT_C TInt BindReal(TInt aParameterIndex, TReal aParameterValue);
854 IMPORT_C TInt BindText(TInt aParameterIndex, const TDesC& aParameterText);
855 IMPORT_C TInt BindBinary(TInt aParameterIndex, const TDesC8& aParameterData);
856 IMPORT_C TInt BindZeroBlob(TInt aParameterIndex, TInt aBlobSize);
858 IMPORT_C TBool IsNull(TInt aColumnIndex) const;
859 IMPORT_C TInt ColumnInt(TInt aColumnIndex) const;
860 IMPORT_C TInt64 ColumnInt64(TInt aColumnIndex) const;
861 IMPORT_C TReal ColumnReal(TInt aColumnIndex) const;
863 IMPORT_C TPtrC ColumnTextL(TInt aColumnIndex) const;
864 IMPORT_C TInt ColumnText(TInt aColumnIndex, TPtrC& aPtr) const;
865 IMPORT_C TInt ColumnText(TInt aColumnIndex, TDes& aDest) const;
867 IMPORT_C TPtrC8 ColumnBinaryL(TInt aColumnIndex) const;
868 IMPORT_C TInt ColumnBinary(TInt aColumnIndex, TPtrC8& aPtr) const;
869 IMPORT_C TInt ColumnBinary(TInt aColumnIndex, TDes8& aDest) const;
871 IMPORT_C TInt ColumnName(TInt aColumnIndex, TPtrC& aNameDest);
872 IMPORT_C TInt ParameterName(TInt aParameterIndex, TPtrC& aNameDest);
873 IMPORT_C TInt ParamName(TInt aParameterIndex, TPtrC& aNameDest);
875 CSqlStatementImpl& Impl() const;
878 CSqlStatementImpl* iImpl;
883 The read stream interface.
885 The class is used for reading the content of a column containing either
886 binary data or text data.
888 The class derives from RReadStream, which means that all RReadStream public
889 member functions and predefined stream operators \>\> can be used to deal
892 If the blob or text data is over 2Mb in size then it is recommended that the
893 RSqlBlobReadStream or TSqlBlob class is used instead. These classes provide
894 a more RAM-efficient way of reading large amounts of blob or text data from
897 The following two cases are typical:
899 CASE 1 - processing large binary column data.
903 <open/create "db" object>;
905 <prepare "stmt" object>;
906 TInt rc = stmt.Next();
909 RSqlColumnReadStream colStream;
910 CleanupClosePushL(colStream);
911 User::LeaveIfError(colStream.ColumnBinary(stmt, <column_number>));
912 TInt size = stmt.ColumnSize(<column_number>);
913 //read the column data in a buffer ("buf" variable).
914 //(or the column data can be retrieved in a smaller portions)
915 colStream.ReadL(buf, size);
917 CleanupStack::PopAndDestroy(&colStream);
925 CASE 2 - processing large text column data.
929 <open/create "db" object>;
931 <prepare "stmt" object>;
932 TInt rc = stmt.Next();
935 RSqlColumnReadStream colStream;
936 CleanupClosePushL(colStream);
937 User::LeaveIfError(colStream.ColumnText(stmt, <column_number>));
938 TInt size = stmt.ColumnSize(<column_number>);
939 //read the column data in a buffer ("buf" variable).
940 //(or the column data can be retrieved in a smaller portions)
941 colStream.ReadL(buf, size);
943 CleanupStack::PopAndDestroy(&colStream);
951 @see RSqlBlobReadStream
957 class RSqlColumnReadStream : public RReadStream
960 IMPORT_C TInt ColumnText(RSqlStatement& aStmt, TInt aColumnIndex);
961 IMPORT_C TInt ColumnBinary(RSqlStatement& aStmt, TInt aColumnIndex);
962 IMPORT_C void ColumnTextL(RSqlStatement& aStmt, TInt aColumnIndex);
963 IMPORT_C void ColumnBinaryL(RSqlStatement& aStmt, TInt aColumnIndex);
968 The write stream interface.
970 The class is used to set binary data or text data into a parameter.
971 This is a also known as binding a parameter.
973 The class derives from RWriteStream, which means that all RWriteStream public
974 member functions and predefined stream operators \<\< can be used to deal with
977 If the blob or text data is over 2Mb in size then it is recommended that the
978 RSqlBlobWriteStream or TSqlBlob class is used instead. These classes provide
979 a more RAM-efficient way of writing large amounts of blob or text data to
982 The following two cases are typical:
984 CASE 1 - binding a large binary parameter.
988 <open/create "db" object>;
990 <prepare "stmt" object>;//The SQL statement references large binary parameter
991 RSqlParamWriteStream paramStream;
992 CleanupClosePushL(paramStream);
993 User::LeaveIfError(paramStream.BindBinary(stmt, <parameter_number>));
994 //Write out the parameter data
995 paramStream.WriteL(..);
996 paramStream << <data>;
999 paramStream.CommitL();
1000 //Continue with the statement processing issuing Next() or Exec().
1001 TInt rc = stmt.Next();//rc = stmt.Exec()
1003 CleanupStack::PopAndDestroy(¶mStream);
1006 CASE 2 - binding a large text parameter.
1010 <open/create "db" object>;
1012 <prepare "stmt" object>;//The SQL statement references large text parameter
1013 RSqlParamWriteStream paramStream;
1014 CleanupClosePushL(paramStream);
1015 User::LeaveIfError(paramStream.BindText(stmt, <parameter_number>));
1016 //Write out the parameter data
1017 paramStream.WriteL(..);
1018 paramStream << <data>;
1021 paramStream.CommitL();
1022 //Continue with the statement processing issuing Next() or Exec().
1023 TInt rc = stmt.Next();//rc = stmt.Exec()
1025 CleanupStack::PopAndDestroy(¶mStream);
1028 @see RSqlBlobWriteStream
1034 class RSqlParamWriteStream : public RWriteStream
1037 IMPORT_C TInt BindText(RSqlStatement& aStmt, TInt aParameterIndex);
1038 IMPORT_C TInt BindBinary(RSqlStatement& aStmt, TInt aParameterIndex);
1039 IMPORT_C void BindTextL(RSqlStatement& aStmt, TInt aParameterIndex);
1040 IMPORT_C void BindBinaryL(RSqlStatement& aStmt, TInt aParameterIndex);
1045 A direct handle to a blob, used for reading the content of the blob via a streaming interface.
1047 The target blob is identified using the relevant database connection, table name,
1048 column name and ROWID of the record to which the blob belongs (also the attached
1049 database name if the blob is contained in an attached database).
1051 A blob in this context refers to the content of a BLOB or TEXT column,
1052 and a read handle can be opened on both types of column.
1053 For TEXT columns it is important to note that no conversions are performed on
1054 data retrieved using this class - the data is returned as a stream of bytes.
1056 The class derives from RReadStream and provides all of its streaming methods.
1057 The SizeL() method can be used to check the total size of the blob, in bytes.
1059 It is strongly recommended to use this class for reading the content of large blobs
1060 because it significantly reduces the amount of RAM that is used when compared to using the
1061 RSqlColumnReadStream, RSqlStatement::ColumnBinary(L) or RSqlStatement::ColumnText(L) APIs.
1063 Specifically, it is recommended to use this class for blobs over 2Mb in size.
1064 Indeed, in some circumstances where very large blobs are in use it may be impossible
1065 to read the blob content using the legacy APIs (due to the server's finite RAM capacity),
1066 and this class may provide the only way to access the data.
1068 The following code illustrates typical use cases of this class:
1070 CASE 1 - reading large blob data from the last inserted record.
1074 CleanupClosePushL(db);
1075 <open/create "db" object>;
1076 RSqlBlobReadStream rdStrm;
1077 CleanupClosePushL(rdStrm);
1078 rdStrm.OpenL(db, <table_name>, <column_name>);
1079 HBufC8* buffer = HBufC8::NewLC(KBlockSize);
1080 TPtr8 bufPtr(buffer->Des());
1081 TInt size = rdStrm.SizeL();
1084 TInt bytesToRead = (size >= KBlockSize) ? KBlockSize : size ;
1085 rdStrm.ReadL(bufPtr, bytesToRead); // read the next block of data
1086 <do something with the block of data>
1087 size =- bytesToRead;
1089 CleanupStack::PopAndDestroy(3); // buffer, rdStrm, db
1092 CASE 2 - reading large blob data from a selection of records.
1096 CleanupClosePushL(db);
1097 <open/create "db" object>;
1099 CleanupClosePushL(stmt);
1100 <prepare "stmt" object to SELECT the ROWIDs of a collection of blob objects>;
1102 while((rc = stmt.Next()) == KSqlAtRow)
1104 TInt64 rowid = stmt.ColumnInt64(0);
1105 RSqlBlobReadStream rdStrm;
1106 CleanupClosePushL(rdStrm);
1107 rdStrm.OpenL(db, <table_name>, <column_name>, rowid);
1109 HBufC8* buffer = HBufC8::NewLC(KBlockSize);
1110 TPtr8 bufPtr(buffer->Des());
1111 TInt size = rdStrm.SizeL();
1114 TInt bytesToRead = (size >= KBlockSize) ? KBlockSize : size ;
1115 rdStrm.ReadL(bufPtr, bytesToRead); // read the next block of data
1116 <do something with the block of data>
1117 size =- bytesToRead;
1119 CleanupStack::PopAndDestroy(2); // buffer, rdStrm
1121 CleanupStack::PopAndDestroy(2); // stmt, db
1124 @see RSqlBlobWriteStream
1125 @see RSqlDatabase::LastInsertedRowId()
1130 class RSqlBlobReadStream : public RReadStream
1133 IMPORT_C void OpenL(RSqlDatabase& aDb, const TDesC& aTableName, const TDesC& aColumnName,
1134 TInt64 aRowId = KSqlLastInsertedRowId, const TDesC& aDbName = KNullDesC);
1135 IMPORT_C TInt SizeL();
1139 A direct handle to a blob, used for writing the content of the blob via a streaming interface.
1141 The target blob is identified using the relevant database connection, table name,
1142 column name and ROWID of the record to which the blob belongs (also the attached
1143 database name if the blob is contained in an attached database).
1145 A blob in this context refers to the content of a BLOB or TEXT column,
1146 and a write handle can be opened on both types of column, except if the
1147 column is indexed, in which case the open call will fail with KSqlErrGeneral.
1148 For TEXT columns it is important to note that no conversions are performed on data
1149 that is stored using this class - the data is simply stored as a stream of bytes.
1151 The class derives from RWriteStream and provides all of its streaming methods.
1152 The SizeL() method can be used to check the total size of the blob, in bytes.
1153 Note that this class cannot be used to increase the size of a blob, only to modify
1154 the existing contents of a blob. An attempt to write beyond the end of a blob will
1157 It is strongly recommended to use this class for writing the content of large blobs
1158 because it significantly reduces the amount of RAM that is used when compared to using
1159 the RSqlParamWriteStream, RSqlStatement::BindBinary or RSqlStatement::BindText APIs.
1161 Specifically, it is recommended to use this class for blobs over 2Mb in size.
1162 Indeed, in some circumstances where very large blobs are required it may be impossible
1163 to create a blob or update its content using the legacy APIs (due to the server's finite
1164 RAM capacity), and this class may provide the only way to achieve this.
1166 Using this class in combination with zeroblobs it is possible to create and manipulate
1167 blobs that are gigabytes in size. A zeroblob acts as a place-holder for a blob whose
1168 content is later written using this class and one can be created using an INSERT
1169 statement that either contains the SQLite 'zeroblob()' function or on which
1170 RSqlStatement::BindZeroBlob() has been executed.
1171 Note that a zeroblob should be created in a column after which there are no columns
1172 that contain anything other than zeroblobs or NULLs, otherwise the zeroblob must be
1173 allocated in full in RAM.
1175 When creating a zeroblob it is recommended, where possible, to create the zeroblob and
1176 then write the blob content within the same transaction. Otherwise the zeroblob will
1177 have to be journalled before being written to.
1179 It is also strongly recommended to execute calls to WriteL() within a transaction.
1180 If a leave occurs during a call to WriteL() then the current state of the blob object is
1181 undefined and a ROLLBACK should be executed to return the blob object to its previous state.
1182 Note that in order for a ROLLBACK to execute successfully all open RSqlBlobReadStream
1183 and RSqlBlobWriteStream handles and all open RSqlStatement objects must be closed
1184 before the ROLLBACK is executed.
1186 The following code illustrates typical use cases of this class:
1188 CASE 1 - creating a 5Mb blob.
1192 CleanupClosePushL(db);
1193 <open/create "db" object>;
1194 CleanupStack::PushL(TCleanupItem(&DoRollback, &db)); // rollback function
1195 TInt err = db.Exec(_L("BEGIN"));
1197 err = db.Exec(_L("INSERT INTO table1 VALUES(35, zeroblob(5242880))"));
1199 RSqlBlobWriteStream wrStrm;
1200 CleanupClosePushL(wrStrm);
1201 wrStrm.OpenL(db, <table_name>, <column_name>);
1202 TInt size = wrStrm.SizeL();
1205 TInt bytesToWrite = (size >= KBlockSize) ? KBlockSize : size ;
1206 <fill a buffer 'buf' with this amount of the blob data>
1207 wrStrm.WriteL(buf); // write the next block of data
1208 size =- bytesToWrite;
1210 CleanupStack::PopAndDestroy(&wrStrm);
1211 CleanupStack::Pop(); // TCleanupItem
1212 err = db.Exec(_L("COMMIT")); // blob data committed to disk
1214 CleanupStack::PopAndDestroy(&db);
1217 CASE 2 - updating a large blob in the last inserted record.
1221 CleanupClosePushL(db);
1222 <open/create "db" object>;
1223 CleanupStack::PushL(TCleanupItem(&DoRollback, &db)); // rollback function
1224 TInt err = db.Exec(_L("BEGIN"));
1226 RSqlBlobWriteStream wrStrm;
1227 CleanupClosePushL(wrStrm);
1228 wrStrm.OpenL(db, <table_name>, <column_name>);
1229 <fill a buffer 'buf' with the changed blob data>
1230 wrStrm.WriteL(buf); // update the blob
1231 CleanupStack::PopAndDestroy(&wrStrm);
1232 CleanupStack::Pop(); // TCleanupItem
1233 err = db.Exec(_L("COMMIT")); // blob data committed to disk
1235 CleanupStack::PopAndDestroy(&db);
1238 @see RSqlBlobReadStream
1239 @see RSqlDatabase::LastInsertedRowId()
1240 @see RSqlStatement::BindZeroBlob()
1245 class RSqlBlobWriteStream : public RWriteStream
1248 IMPORT_C void OpenL(RSqlDatabase& aDb, const TDesC& aTableName, const TDesC& aColumnName,
1249 TInt64 aRowId = KSqlLastInsertedRowId, const TDesC& aDbName = KNullDesC);
1250 IMPORT_C TInt SizeL();
1254 Utility class that provides methods for reading and writing the entire content of
1255 a blob in a single call.
1257 The target blob is identified using the relevant database connection, table name,
1258 column name and ROWID of the record to which the blob belongs (also the attached
1259 database name if the blob is contained in an attached database).
1261 The behaviour of the RSqlBlobReadStream class and the recommendations for using
1262 it exist for the Get() and GetLC() methods of this class. Similarly, the behaviour
1263 of the RSqlBlobWriteStream class and the recommendations for using it exist for the
1264 SetL() method of this class.
1266 In particular, it is strongly recommended to use this class or the RSqlBlobReadStream
1267 and RSqlBlobWriteStream classes for reading and writing the content of large blobs
1268 because it significantly reduces the amount of RAM that is used when compared to using
1269 the legacy streaming and RSqlStatement APIs.
1271 Specifically, it is recommended to use this class for blobs over 2Mb in size.
1272 Indeed, in some circumstances where very large blobs are in use it may be impossible
1273 to read or write to a blob using the legacy APIs (due to the server's finite
1274 RAM capacity), and this class or the RSqlBlobReadStream and RSqlBlobWriteStream classes
1275 may provide the only way to achieve this.
1277 It is strongly recommended to execute calls to the SetL() method within a transaction.
1278 If a leave occurs during a call to SetL() then the current state of the blob object is
1279 undefined and a ROLLBACK should be executed to return the blob object to its previous state.
1280 Note that in order for a ROLLBACK to execute successfully all open RSqlBlobReadStream
1281 and RSqlBlobWriteStream handles and all open RSqlStatement objects must be closed
1282 before the ROLLBACK is executed.
1284 When using SetL() to update the content of a zeroblob it is recommended, where possible,
1285 to create the zeroblob and then call SetL() within the same transaction.
1286 Otherwise the zeroblob will have to be journalled before being written to.
1288 The following code illustrates typical use cases of this class:
1290 CASE 1 - retrieving the entire content of a large blob.
1294 CleanupClosePushL(db);
1295 <open/create "db" object>;
1296 HBufC8* wholeBlob = TSqlBlob::GetLC(db, <table_name>, <column_name>, <rowid>);
1297 <do something with the blob data>
1298 CleanupStack::PopAndDestroy(2); // wholeBlob, db
1302 CASE 2 - creating a 4Mb blob.
1306 CleanupClosePushL(db);
1307 <open/create "db" object>;
1308 CleanupStack::PushL(TCleanupItem(&DoRollback, &db)); // rollback function
1309 TInt err = db.Exec(_L("BEGIN"));
1311 err = db.Exec(_L("INSERT INTO table1 VALUES(99, zeroblob(4194304))"));
1313 <fill a buffer 'buf' with 4Mb of blob data>
1314 TSqlBlob::SetL(db, <table_name>, <column_name>, buf);
1315 CleanupStack::Pop(); // TCleanupItem
1316 err = db.Exec(_L("COMMIT")); // blob data committed to disk
1318 CleanupStack::PopAndDestroy(&db);
1321 @see RSqlBlobReadStream
1322 @see RSqlBlobWriteStream
1323 @see RSqlDatabase::LastInsertedRowId()
1324 @see RSqlStatement::BindZeroBlob()
1332 IMPORT_C static HBufC8* GetLC(RSqlDatabase& aDb,
1333 const TDesC& aTableName,
1334 const TDesC& aColumnName,
1335 TInt64 aRowId = KSqlLastInsertedRowId,
1336 const TDesC& aDbName = KNullDesC);
1338 IMPORT_C static TInt Get(RSqlDatabase& aDb,
1339 const TDesC& aTableName,
1340 const TDesC& aColumnName,
1342 TInt64 aRowId = KSqlLastInsertedRowId,
1343 const TDesC& aDbName = KNullDesC);
1345 IMPORT_C static void SetL(RSqlDatabase& aDb,
1346 const TDesC& aTableName,
1347 const TDesC& aColumnName,
1348 const TDesC8& aData,
1349 TInt64 aRowId = KSqlLastInsertedRowId,
1350 const TDesC& aDbName = KNullDesC);
1354 Defines a set of categories for the values returned by the SQL API.
1356 A call to an SQL API may complete with a non-zero return code indicating that some
1357 unexpected behaviour has occurred. This can be categorised in a number of ways,
1358 for example, as a Symbian OS error, or as a database error etc.
1360 Callers to the SQL API may not want to be concerned with the detailed meaning of
1361 a specific return code value, and may find it sufficient just to know the category
1364 The category associated with a specific return code can be found by passing the
1365 return code value to the function SqlRetCodeClass().
1370 enum TSqlRetCodeClass
1373 Indicates that a return code is just for information.
1375 This category corresponds to the SQL API return codes: KSqlAtRow and KSqlAtEnd.
1377 @see SqlRetCodeClass()
1378 @see TSqlRetCodeClass
1385 Indicates that a return code represents a database-specific error.
1387 This category corresponds to SQL API return codes in the range KSqlErrGeneral to KSqlErrStmtExpired.
1389 @see SqlRetCodeClass()
1390 @see TSqlRetCodeClass
1392 @see KSqlErrStmtExpired
1397 Indicates that a return code represents a Symbian OS error.
1399 This category corresponds to SQL API return codes in the range KErrPermissionDenied to KErrNone,
1401 @see SqlRetCodeClass()
1402 @see TSqlRetCodeClass
1403 @see KErrPermissionDenied
1410 An information type return code from a call to RSqlStatement::Next().
1412 It means that the RSqlStatement object points to a valid row, and that
1413 the user can access the column data using the appropriate RSqlStatement
1416 @see RSqlStatement::Next()
1418 @see ESqlInformation
1419 @see TSqlRetCodeClass
1424 const TInt KSqlAtRow = 1;
1427 An information type return code from a call to RSqlStatement::Next().
1429 It means that the RSqlStatement object does not point to a valid row,
1430 and that column data accessors cannot be used.
1432 @see RSqlStatement::Next()
1434 @see ESqlInformation
1435 @see TSqlRetCodeClass
1440 const TInt KSqlAtEnd = 2;
1443 An SQL database-specific error type return code from a call to the SQL API.
1445 It indicates a general SQL error or a missing database.
1449 @see TSqlRetCodeClass
1454 const TInt KSqlErrGeneral = -311;
1457 An SQL database-specific error type return code from a call to the SQL API.
1459 It indicates an internal logic error in the SQL database engine, and specifically
1460 that an internal consistency check within the SQL database engine has failed.
1464 @see TSqlRetCodeClass
1469 const TInt KSqlErrInternal = -312;
1472 An SQL database-specific error type return code from a call to the SQL API.
1474 It indicates that access permission has been denied.
1478 @see TSqlRetCodeClass
1483 const TInt KSqlErrPermission = -313;
1486 An SQL database-specific error type return code from a call to the SQL API.
1488 It indicates an internal logic error in the SQL database engine, and specifically
1489 that a callback routine requested an abort.
1494 const TInt KSqlErrAbort = -314;
1497 An SQL database-specific error type return code from a call to the SQL API.
1499 It indicates that the database file is locked.
1503 @see TSqlRetCodeClass
1508 const TInt KSqlErrBusy = -315;
1511 An SQL database-specific error type return code from a call to the SQL API.
1513 It indicates that a table in the database is locked.
1517 @see TSqlRetCodeClass
1522 const TInt KSqlErrLocked = -316;
1525 An SQL database-specific error type return code from a call to the SQL API.
1527 It indicates an attempt to write to a database that is read-only.
1531 @see TSqlRetCodeClass
1536 const TInt KSqlErrReadOnly = -318;
1539 SQL database-specific error type. Operation terminated.
1544 const TInt KSqlErrInterrupt = -319;
1547 An SQL database-specific error type return code from a call to the SQL API.
1549 It indicates that a disk I/O error has occurred.
1553 @see TSqlRetCodeClass
1558 const TInt KSqlErrIO = -320;
1561 An SQL database-specific error type return code from a call to the SQL API.
1563 It indicates that the database disk image is malformed.
1567 @see TSqlRetCodeClass
1572 const TInt KSqlErrCorrupt = -321;
1575 SQL database-specific error type. Table or record not found.
1580 const TInt KSqlErrNotFound = -322;
1583 An SQL database-specific error type return code from a call to the SQL API.
1585 It indicates that an insertion operation has failed because an autoincrement column used up
1586 all awailable rowids.
1590 @see TSqlRetCodeClass
1595 const TInt KSqlErrFull = -323;
1598 An SQL database-specific error type return code from a call to the SQL API.
1600 It indicates a failure to open the database file.
1604 @see TSqlRetCodeClass
1609 const TInt KSqlErrCantOpen = -324;
1612 An SQL database-specific error type return code from a call to the SQL API.
1614 It indicates a database lock protocol error.
1618 @see TSqlRetCodeClass
1623 const TInt KSqlErrProtocol = -325;
1626 An SQL database-specific error type return code from a call to the SQL API.
1628 It indicates that the database is empty.
1632 @see TSqlRetCodeClass
1637 const TInt KSqlErrEmpty = -326;
1640 An SQL database-specific error type return code from a call to the SQL API.
1642 It indicates that a prepared SQL statement is no longer valid
1643 and cannot be executed.
1645 The most common reason for this return code is that the database schema was modified after
1646 the SQL statement was prepared. The SQL statement must be prepared again
1647 using the RSqlStatement::Prepare() member functions.
1649 Another possible reason for this return code is a detached database.
1653 @see TSqlRetCodeClass
1658 const TInt KSqlErrSchema = -327;
1661 SQL database-specific error type. Too much data for one row.
1666 const TInt KSqlErrTooBig = -328;
1669 An SQL database-specific error type return code from a call to the SQL API.
1671 It indicates an abort due to constraint violation.
1673 "Constraint violation" means violation of one or more column constraints ("NOT NULL", "PRIMARY KEY",
1674 "UNIQUE", "CHECK", "DEFAULT", "COLLATE" SQL keywords) or table constraints ("PRIMARY KEY", "UNIQUE",
1675 "CHECK" SQL keywords).
1679 @see TSqlRetCodeClass
1684 const TInt KSqlErrConstraint = -329;
1687 An SQL database-specific error type return code from a call to the SQL API.
1689 It indicates a data type mismatch.
1693 @see TSqlRetCodeClass
1698 const TInt KSqlErrMismatch = -330;
1701 An SQL database-specific error type return code from a call to the SQL API.
1703 It indicates an internal logic error in the SQL database engine.
1707 @see TSqlRetCodeClass
1712 const TInt KSqlErrMisuse = -331;
1715 An SQL database-specific error type return code from a call to the SQL API.
1717 It indicates that a parameter index value is out of range.
1721 @see TSqlRetCodeClass
1726 const TInt KSqlErrRange = -335;
1729 An SQL database-specific error type return code from a call to the SQL API.
1731 It indicates that the file that has been opened is not a database file.
1735 @see TSqlRetCodeClass
1740 const TInt KSqlErrNotDb = -336;
1743 An SQL database-specific error type return code from a call to the SQL API.
1745 It indicates that an SQL statement has expired, and needs to be prepared again.
1749 @see TSqlRetCodeClass
1754 const TInt KSqlErrStmtExpired = -360;
1756 IMPORT_C TSqlRetCodeClass SqlRetCodeClass(TInt aSqlRetCode);
1758 #endif //__SQLDB_H__