persistentstorage/sql/SRC/Client/SqlStmtSession.inl
changeset 31 ba1c4f4a893f
parent 0 08ec8eefde2f
child 45 cc28652e0254
equal deleted inserted replaced
29:cce6680bbf1c 31:ba1c4f4a893f
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    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 /**
       
    90 @panic SqlDb 2 In _DEBUG mode if the statement handle is 0 or the database session is NULL,
    19 @panic SqlDb 2 In _DEBUG mode if the statement handle is 0 or the database session is NULL,
    91 			   i.e. Prepare() has not yet been called on this RSqlStatementSession object.
    20 			   i.e. Prepare() has not yet been called on this RSqlStatementSession object.
    92 			   
    21 			   
    93 @return A reference to the RSqlDbSession instance.
    22 @return A reference to the RSqlDbSession instance.
    94 */
    23 */
    95 inline RSqlDbSession& RSqlStatementSession::DbSession() const
    24 inline RSqlDbSession& RSqlStatementSession::DbSession() const
    96 	{
    25 	{
    97 	__SQLASSERT(iHandle > 0 && iDbSession != NULL, ESqlPanicInvalidObj);
    26 	__ASSERT_DEBUG(iHandle > 0 && iDbSession != NULL, __SQLPANIC(ESqlPanicInvalidObj));
    98 	return *iDbSession;
    27 	return *iDbSession;
    99 	}
    28 	}
   100 
    29 
   101 /**
    30 /**
   102 Creates unitialized RSqlStatementSession object.
    31 Creates unitialized RSqlStatementSession object.