|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __SQLDATABASEIMPL_H__ |
|
17 #define __SQLDATABASEIMPL_H__ |
|
18 |
|
19 #include <sqldb.h> //RSqlDatabase::TIsolationLevel, TSqlColumnType |
|
20 #include "SqlDbSession.h" //RSqlDbSession, TSqlSrvFunction (via included SqlUtil.h) |
|
21 |
|
22 //Forward declarations |
|
23 class CSqlSecurityPolicy; |
|
24 |
|
25 /** |
|
26 CSqlDatabaseImpl implements RSqlDatabase. |
|
27 |
|
28 It can be used for: |
|
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 ";"; |
|
32 - deleting databases; |
|
33 - retrieving last error messages; |
|
34 - setting the isolation level; |
|
35 - returning the database security policy; |
|
36 |
|
37 @see RSqlDatabase |
|
38 |
|
39 @internalComponent |
|
40 */ |
|
41 NONSHARABLE_CLASS(CSqlDatabaseImpl) : public CBase |
|
42 { |
|
43 public: |
|
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(); |
|
63 inline TInt Size(); |
|
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); |
|
67 |
|
68 private: |
|
69 inline CSqlDatabaseImpl(); |
|
70 void ConstructL(TSqlSrvFunction aFunction, const TDesC& aDbFileName, |
|
71 const CSqlSecurityPolicy* aSecurityPolicy = NULL, const TDesC8* aConfig = NULL); |
|
72 |
|
73 private: |
|
74 RSqlDbSession iDbSession; |
|
75 |
|
76 }; |
|
77 |
|
78 #include "SqlDatabaseImpl.inl" |
|
79 |
|
80 #endif //__SQLDATABASEIMPL_H__ |