Update contrib.
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 __SQLDBSESSION_H__
17 #define __SQLDBSESSION_H__
19 #include <sqldb.h> //RSqlDatabase::TIsolationLevel
20 #include "SqlUtil.h" //TSqlSrvFunction
22 //Forward declarations
24 class RSqlStatementSession;
25 class TSqlResourceTestData;
26 class CSqlSecurityPolicy;
28 class TSqlFhCmdFunctor;
30 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
31 ////////////////////// RSqlDbSession /////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
35 RSqlDbSession class is used for establishing a connection with the database server.
36 It can be used also for:
37 - executing SQL statements or a set of SQL statements, separated with ";";
38 - attaching/detaching databases;
41 - retrieving last error messages;
45 NONSHARABLE_CLASS(RSqlDbSession) : public RSessionBase
47 //RSqlDbSession class hides all details about the communication with the database server.
48 //No database specific header files should be seen or used outside the session class.
50 friend class RSqlStatementSession;
51 friend class TSqlResourceTestData;
54 inline RSqlDbSession();
55 TInt Connect(TSqlSrvFunction aFunction, const TDesC& aDbFileName, const TDesC8& aSecurityPolicyData, const TDesC8* aConfig);
56 TInt Attach(const TDesC& aDbFileName, const TDesC& aDbName);
57 inline TInt Detach(const TDesC& aDbName);
58 static TInt CopyDatabase(const TDesC& aSrcDbFileName, const TDesC& aDestDbFileName);
59 static TInt DeleteDatabase(const TDesC& aDbFileName);
60 TPtrC LastErrorMessage();
61 TInt64 LastInsertedRowId();
62 inline TInt Exec(const TDesC& aSqlStmt);
63 inline TInt Exec(const TDesC8& aSqlStmt);
64 inline void Exec(const TDesC& aSqlStmt, TRequestStatus& aStatus);
65 inline void Exec(const TDesC8& aSqlStmt, TRequestStatus& aStatus);
66 inline TInt SetIsolationLevel(RSqlDatabase::TIsolationLevel aIsolationLevel);
67 TInt GetSecurityPolicy(RSqlBufFlat& aSecurityPolicyBuf);
68 inline TInt ExecScalarFullSelect(const TDesC& aSqlStmt, TSqlColumnType aType, TDes8& aRes);
69 inline TInt ExecScalarFullSelect(const TDesC8& aSqlStmt, TSqlColumnType aType, TDes8& aRes);
72 inline TInt SendReceive(TInt aFunction);
73 inline void SendReceive(TInt aFunction, TRequestStatus& aStatus);
74 inline TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs);
75 inline void SendReceive(TInt aFunction,const TIpcArgs& aArgs, TRequestStatus& aStatus);
78 enum TDbfAction {EDbfCreate, EDbfOpen};
79 TInt DoCreateSession();
80 TInt InitResourceTestData();
81 TInt CreateAndSendFileHandle(TSqlFhCmdFunctor& aFhCmdSender, TDbfAction aDbfAction);
82 TInt DoConnect(TSqlSrvFunction aFunction, const TDesC& aDbFileName, const TDesC8& aSecurityPolicyData, const TDesC8* aConfig);
85 HBufC* iLastErrorMessage;
89 #include "SqlDbSession.inl"
91 #endif //__SQLDBSESSION_H__