14 // Description: |
14 // Description: |
15 // |
15 // |
16 |
16 |
17 #include <s32mem.h> |
17 #include <s32mem.h> |
18 #include "SqlStmtSession.h" //RSqlStatementSession |
18 #include "SqlStmtSession.h" //RSqlStatementSession |
|
19 #include "OstTraceDefinitions.h" |
|
20 #ifdef OST_TRACE_COMPILER_IN_USE |
|
21 #include "SqlStmtSessionTraces.h" |
|
22 #endif |
|
23 #include "SqlTraceDef.h" |
|
24 |
|
25 /** |
|
26 Sends a request to the SQL server to prepare 16-bit aSqlStmt statement. |
|
27 |
|
28 Usage of the IPC call arguments: |
|
29 Arg 0: [in/out] data buffer for the column and parameter count. |
|
30 Arg 1: [out] statement length in characters |
|
31 Arg 2: [out] 16-bit statement |
|
32 |
|
33 @param aDbSession A reference to RSqlDbSession instance. |
|
34 @param aSqlStmt 16-bit SQL statement. |
|
35 @param aColumnCount Output parameter. Statement column count. |
|
36 @param aParamCount Output parameter. Statement parameter count. |
|
37 |
|
38 @return KErrNoMemory, an out of memory condition has occured; |
|
39 KErrArgument, bad argument, for example - the SQL string contains more than one SQL statements. |
|
40 Note that the function may return some database specific errors categorised as |
|
41 ESqlDbError or other system-wide error codes; |
|
42 KErrNone The operation has completed successfully. |
|
43 |
|
44 @panic SqlDb 7 In _DEBUG mode if the statement handle is 0. |
|
45 */ |
|
46 TInt RSqlStatementSession::Prepare(RSqlDbSession& aDbSession, const TDesC& aSqlStmt, |
|
47 TInt& aColumnCount, TInt& aParamCount) |
|
48 { |
|
49 iDbSession = &aDbSession; |
|
50 TSqlIpcData data; |
|
51 TPckg<TSqlIpcData> pckg(data); |
|
52 TUint stmtLen = aSqlStmt.Length(); |
|
53 iHandle = iDbSession->SendReceive(ESqlSrvStmtPrepare16, TIpcArgs(&pckg, stmtLen, &aSqlStmt)); |
|
54 __ASSERT_DEBUG(iHandle != 0, __SQLPANIC(ESqlPanicInternalError)); |
|
55 aColumnCount = static_cast <TInt> (data.iPrm1); |
|
56 aParamCount = static_cast <TInt> (data.iPrm2); |
|
57 SQL_TRACE_SESSION(OstTraceExt2(TRACE_INTERNALS, RSQLSTATEMENTSESSION_PREPARE16, "0x%X;RSqlStatementSession::Prepare-16;iHandle=%d", (TUint)this, iHandle)); |
|
58 return iHandle > 0 ? KErrNone : iHandle; |
|
59 } |
|
60 |
|
61 /** |
|
62 Sends a request to the SQL server to prepare 8-bit aSqlStmt statement. |
|
63 |
|
64 Usage of the IPC call arguments: |
|
65 Arg 0: [in/out] data buffer for the column and parameter count. |
|
66 Arg 1: [out] statement length in characters |
|
67 Arg 2: [out] 8-bit statement |
|
68 |
|
69 @param aDbSession A reference to RSqlDbSession instance. |
|
70 @param aSqlStmt 8-bit SQL statement. |
|
71 @param aColumnCount Output parameter. Statement column count. |
|
72 @param aParamCount Output parameter. Statement parameter count. |
|
73 |
|
74 @return KErrNoMemory, an out of memory condition has occured; |
|
75 KErrArgument, bad argument, for example - the SQL string contains more than one SQL statements. |
|
76 Note that the function may return some database specific errors categorised as |
|
77 ESqlDbError or other system-wide error codes; |
|
78 KErrNone The operation has completed successfully. |
|
79 |
|
80 @panic SqlDb 7 In _DEBUG mode if the statement handle is 0. |
|
81 */ |
|
82 TInt RSqlStatementSession::Prepare(RSqlDbSession& aDbSession, const TDesC8& aSqlStmt, |
|
83 TInt& aColumnCount, TInt& aParamCount) |
|
84 { |
|
85 iDbSession = &aDbSession; |
|
86 TSqlIpcData data; |
|
87 TPckg<TSqlIpcData> pckg(data); |
|
88 TUint stmtLen = aSqlStmt.Length(); |
|
89 iHandle = iDbSession->SendReceive(ESqlSrvStmtPrepare8, TIpcArgs(&pckg, stmtLen, &aSqlStmt)); |
|
90 __ASSERT_DEBUG(iHandle != 0, __SQLPANIC(ESqlPanicInternalError)); |
|
91 aColumnCount = static_cast <TInt> (data.iPrm1); |
|
92 aParamCount = static_cast <TInt> (data.iPrm2); |
|
93 SQL_TRACE_SESSION(OstTraceExt2(TRACE_INTERNALS, RSQLSTATEMENTSESSION_PREPARE8, "0x%X;RSqlStatementSession::Prepare-8;iHandle=%d", (TUint)this, iHandle)); |
|
94 return iHandle > 0 ? KErrNone : iHandle; |
|
95 } |
19 |
96 |
20 /** |
97 /** |
21 Sends a request to the server to close the statement handle. |
98 Sends a request to the server to close the statement handle. |
22 Closes the session object. |
99 Closes the session object. |
23 */ |
100 */ |
24 void RSqlStatementSession::Close() |
101 void RSqlStatementSession::Close() |
25 { |
102 { |
|
103 SQL_TRACE_SESSION(OstTraceExt2(TRACE_INTERNALS, RSQLSTATEMENTSESSION_CLOSE, "0x%X;RSqlStatementSession::Close;iHandle=%d", (TUint)this, iHandle)); |
26 if(iDbSession && iHandle > 0) |
104 if(iDbSession && iHandle > 0) |
27 { |
105 { |
28 (void)iDbSession->SendReceive(::MakeMsgCode(ESqlSrvStmtClose, ESqlSrvStatementHandle, iHandle)); |
106 (void)iDbSession->SendReceive(::MakeMsgCode(ESqlSrvStmtClose, ESqlSrvStatementHandle, iHandle)); |
29 } |
107 } |
30 iDbSession = NULL; |
108 iDbSession = NULL; |