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