persistentstorage/sql/SRC/Client/SqlStmtSession.inl
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
--- a/persistentstorage/sql/SRC/Client/SqlStmtSession.inl	Tue Aug 31 16:57:14 2010 +0300
+++ b/persistentstorage/sql/SRC/Client/SqlStmtSession.inl	Wed Sep 01 12:39:58 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -16,6 +16,77 @@
 //
 
 /**
+ 
+ Sends a request to the SQL server to prepare 16-bit aSqlStmt statement.
+ 
+ Usage of the IPC call arguments:
+ Arg 0: [in/out]		data buffer for the column and parameter count.
+ Arg 1: [out]		statement length in characters
+ Arg 2: [out]		16-bit statement
+ 
+ @param aDbSession A reference to RSqlDbSession instance.
+ @param aSqlStmt 16-bit SQL statement.
+ @param aColumnCount Output parameter. Statement column count.
+ @param aParamCount Output parameter. Statement parameter count.
+ 
+ @return KErrNoMemory, an out of memory condition has occured;
+ KErrArgument, bad argument, for example - the SQL string contains more than one SQL statements.
+ Note that the function may leave with some database specific errors categorised as 
+ ESqlDbError or other system-wide error codes;
+ KErrNone      The operation has completed successfully. 
+ 
+ @panic SqlDb 7 In _DEBUG mode if the statement handle is 0.
+*/
+inline TInt RSqlStatementSession::Prepare(RSqlDbSession& aDbSession, const TDesC& aSqlStmt, 
+										  TInt& aColumnCount, TInt& aParamCount)
+	{
+	iDbSession = &aDbSession;
+	TSqlIpcData data;
+	TPckg<TSqlIpcData> pckg(data);
+	TUint stmtLen = aSqlStmt.Length();
+	iHandle = iDbSession->SendReceive(ESqlSrvStmtPrepare16, TIpcArgs(&pckg, stmtLen, &aSqlStmt));
+	__SQLASSERT(iHandle != 0, ESqlPanicInternalError);	
+	aColumnCount = static_cast <TInt> (data.iPrm1);
+	aParamCount = static_cast <TInt> (data.iPrm2);
+	return iHandle > 0 ? KErrNone : iHandle;
+	}
+
+/**
+Sends a request to the SQL server to prepare 8-bit aSqlStmt statement.
+
+Usage of the IPC call arguments:
+Arg 0: [in/out]		data buffer for the column and parameter count.
+Arg 1: [out]		statement length in characters
+Arg 2: [out]		8-bit statement
+
+@param aDbSession A reference to RSqlDbSession instance.
+@param aSqlStmt 8-bit SQL statement.
+@param aColumnCount Output parameter. Statement column count.
+@param aParamCount Output parameter. Statement parameter count.
+
+@return KErrNoMemory, an out of memory condition has occured;
+	    KErrArgument, bad argument, for example - the SQL string contains more than one SQL statements.
+                      Note that the function may leave with some database specific errors categorised as 
+                      ESqlDbError or other system-wide error codes;
+        KErrNone      The operation has completed successfully. 
+
+@panic SqlDb 7 In _DEBUG mode if the statement handle is 0.
+*/
+inline TInt RSqlStatementSession::Prepare(RSqlDbSession& aDbSession, const TDesC8& aSqlStmt, 
+										  TInt& aColumnCount, TInt& aParamCount)
+	{
+	iDbSession = &aDbSession;
+	TSqlIpcData data;
+	TPckg<TSqlIpcData> pckg(data);
+	TUint stmtLen = aSqlStmt.Length();
+	iHandle = iDbSession->SendReceive(ESqlSrvStmtPrepare8, TIpcArgs(&pckg, stmtLen, &aSqlStmt));
+	__SQLASSERT(iHandle != 0, ESqlPanicInternalError);
+	aColumnCount = static_cast <TInt> (data.iPrm1);
+	aParamCount = static_cast <TInt> (data.iPrm2);
+	return iHandle > 0 ? KErrNone : iHandle;
+	}
+
+/**
 @panic SqlDb 2 In _DEBUG mode if the statement handle is 0 or the database session is NULL,
 			   i.e. Prepare() has not yet been called on this RSqlStatementSession object.
 			   
@@ -23,7 +94,7 @@
 */
 inline RSqlDbSession& RSqlStatementSession::DbSession() const
 	{
-	__ASSERT_DEBUG(iHandle > 0 && iDbSession != NULL, __SQLPANIC(ESqlPanicInvalidObj));
+	__SQLASSERT(iHandle > 0 && iDbSession != NULL, ESqlPanicInvalidObj);
 	return *iDbSession;
 	}