First public contribution.
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.
16 #ifndef __SQLDATABASEIMPL_H__
17 #define __SQLDATABASEIMPL_H__
19 #include <sqldb.h> //RSqlDatabase::TIsolationLevel, TSqlColumnType
20 #include "SqlDbSession.h" //RSqlDbSession, TSqlSrvFunction (via included SqlUtil.h)
22 //Forward declarations
23 class CSqlSecurityPolicy;
26 CSqlDatabaseImpl implements RSqlDatabase.
29 - establishing a connection with the database;
30 - attaching/detaching a database to/from the existing connection;
31 - executing SQL statements or a set of SQL statements, separated with ";";
33 - retrieving last error messages;
34 - setting the isolation level;
35 - returning the database security policy;
41 NONSHARABLE_CLASS(CSqlDatabaseImpl) : public CBase
44 static CSqlDatabaseImpl* NewL(TSqlSrvFunction aFunction, const TDesC& aDbFileName,
45 const CSqlSecurityPolicy* aSecurityPolicy, const TDesC8* aConfig = NULL);
46 virtual ~CSqlDatabaseImpl();
47 inline TInt Attach(const TDesC& aDbFileName, const TDesC& aDbName);
48 inline TInt Detach(const TDesC& aDbName);
49 static inline TInt Copy(const TDesC& aSrcDbFileName, const TDesC& aDestDbFileName);
50 static inline TInt Delete(const TDesC& aDbFileName);
51 CSqlSecurityPolicy* CloneSecurityPolicyL();
52 inline TInt SetIsolationLevel(RSqlDatabase::TIsolationLevel aIsolationLevel);
53 inline TInt Exec(const TDesC16& aSqlStmt);
54 inline TInt Exec(const TDesC8& aSqlStmt);
55 inline void Exec(const TDesC16& aSqlStmt, TRequestStatus& aStatus);
56 inline void Exec(const TDesC8& aSqlStmt, TRequestStatus& aStatus);
57 inline TPtrC LastErrorMessage();
58 inline TInt64 LastInsertedRowId();
59 inline RSqlDbSession& Session();
60 inline TInt ExecScalarFullSelectL(const TDesC16& aSqlStmt, TSqlColumnType aType, TDes8& aRes);
61 inline TInt ExecScalarFullSelectL(const TDesC8& aSqlStmt, TSqlColumnType aType, TDes8& aRes);
62 inline TBool InTransaction();
64 inline TInt Size(RSqlDatabase::TSize& aSize, const TDesC& aDbName);
65 TInt Compact(TInt aSize, const TDesC& aDbName);
66 void Compact(TInt aSize, const TDesC& aDbName, TRequestStatus& aStatus);
69 inline CSqlDatabaseImpl();
70 void ConstructL(TSqlSrvFunction aFunction, const TDesC& aDbFileName,
71 const CSqlSecurityPolicy* aSecurityPolicy = NULL, const TDesC8* aConfig = NULL);
74 RSqlDbSession iDbSession;
78 #include "SqlDatabaseImpl.inl"
80 #endif //__SQLDATABASEIMPL_H__