os/persistentdata/persistentstorage/sql/SRC/Client/SqlStatement.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include "SqlStatementImpl.h"		//CSqlStatementImpl
sl@0
    17
#include "OstTraceDefinitions.h"
sl@0
    18
#ifdef OST_TRACE_COMPILER_IN_USE
sl@0
    19
#include "SqlStatementTraces.h"
sl@0
    20
#endif
sl@0
    21
#include "SqlTraceDef.h"
sl@0
    22
sl@0
    23
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    24
sl@0
    25
/**
sl@0
    26
Initialises the pointer to the implementation object to NULL.
sl@0
    27
sl@0
    28
@capability None
sl@0
    29
*/
sl@0
    30
EXPORT_C RSqlStatement::RSqlStatement() :
sl@0
    31
	iImpl(NULL)
sl@0
    32
	{
sl@0
    33
	}
sl@0
    34
sl@0
    35
/**
sl@0
    36
Prepares the supplied 16-bit SQL statement for execution.
sl@0
    37
sl@0
    38
An RSqlStatement object can prepare and execute a parameterised SQL statement or
sl@0
    39
an SQL statement without parameters.
sl@0
    40
sl@0
    41
The function can only deal with one SQL statement at a time, i.e. if you
sl@0
    42
supply more than one SQL statement, each separated by a ";" character, then
sl@0
    43
the function returns an error.
sl@0
    44
sl@0
    45
Note that when the statement is to be used to retrieve or write blob or text data
sl@0
    46
that is over 2Mb in size then it is recommended that the RSqlBlobReadStream and 
sl@0
    47
RSqlBlobWriteStream classes or the TSqlBlob class is used instead. 
sl@0
    48
These classes provide a more RAM-efficient way of reading and writing large 
sl@0
    49
amounts of blob or text data from a database.
sl@0
    50
sl@0
    51
@param aDatabase     A reference to the RSqlDatabase object that represents 
sl@0
    52
                     the database for which the SQL statement is being prepared.
sl@0
    53
@param aSqlStmt      A string of 16-bit wide characters containing the
sl@0
    54
                     SQL statement to be prepared.
sl@0
    55
sl@0
    56
@return KErrNone,     the SQL statement has been prepared for execution successfully;
sl@0
    57
        KErrNoMemory, an out of memory condition has occurred;
sl@0
    58
        KErrArgument, the SQL statement is invalid, for example, the supplied
sl@0
    59
                      string contains more than one SQL statement, or it
sl@0
    60
                      contains an empty SQL statement.
sl@0
    61
                      Note that database specific errors categorised as ESqlDbError
sl@0
    62
                      can also be returned;
sl@0
    63
        KSqlErrGeneral, a syntax error has occurred - text describing the problem
sl@0
    64
                        can be obtained by calling 	RSqlDatabase::LastErrorMessage().
sl@0
    65
		KErrPermissionDenied, the calling application does not satisfy the relevant database security policies.
sl@0
    66
                      Note that database specific errors categorised as ESqlDbError, and
sl@0
    67
                      other system-wide error codes may also be returned.
sl@0
    68
sl@0
    69
@capability None, if current RSqlStatement object represents a handle which operates on a non-secure database;
sl@0
    70
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement modifies a secure database schema; 
sl@0
    71
            RSqlSecurityPolicy::EReadPolicy or 
sl@0
    72
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement reads from a secure database; 
sl@0
    73
            RSqlSecurityPolicy::EWritePolicy or
sl@0
    74
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement writes to a secure database;
sl@0
    75
sl@0
    76
@see TSqlRetCodeClass::ESqlDbError
sl@0
    77
@see RSqlDatabase
sl@0
    78
@see RSqlDatabase::LastErrorMessage()
sl@0
    79
@see RSqlSecurityPolicy
sl@0
    80
@see RSqlSecurityPolicy::TPolicyType
sl@0
    81
@see RSqlBlobReadStream
sl@0
    82
@see RSqlBlobWriteStream
sl@0
    83
@see TSqlBlob
sl@0
    84
*/	
sl@0
    85
EXPORT_C TInt RSqlStatement::Prepare(RSqlDatabase& aDatabase, const TDesC& aSqlStmt)
sl@0
    86
	{
sl@0
    87
    SQL_TRACE_BORDER(OstTraceExt3(TRACE_BORDER, RSQLSTATEMENT_PREPARE16_ENTRY, "Entry;0x%X;RSqlStatement::Prepare16;aDatabase=0x%X;aSqlStmt=%S", (TUint)this, (TUint)&aDatabase, __SQLPRNSTR(aSqlStmt)));
sl@0
    88
	TInt err = CSqlStatementImpl::New(iImpl, aDatabase.Impl(), aSqlStmt);
sl@0
    89
    SQL_TRACE_BORDER(OstTraceExt3(TRACE_BORDER, RSQLSTATEMENT_PREPARE16_EXIT, "Exit;0x%X;RSqlStatement::Prepare16;iImpl=0x%X;err=%d", (TUint)this, (TUint)iImpl, err));
sl@0
    90
	return err;
sl@0
    91
	}
sl@0
    92
	
sl@0
    93
/**
sl@0
    94
Prepares the supplied 8-bit SQL statement for execution.
sl@0
    95
sl@0
    96
An RSqlStatement object can prepare and execute a parameterised SQL statement or
sl@0
    97
an SQL statement without parameters.
sl@0
    98
sl@0
    99
The function can only deal with one SQL statement at a time, i.e. if you
sl@0
   100
supply more than one SQL statement, each separated by a ";" character, then
sl@0
   101
the function returns an error.
sl@0
   102
sl@0
   103
Note that when the statement is to be used to retrieve or write blob or text data
sl@0
   104
that is over 2Mb in size then it is recommended that the RSqlBlobReadStream and 
sl@0
   105
RSqlBlobWriteStream classes or the TSqlBlob class is used instead. 
sl@0
   106
These classes provide a more RAM-efficient way of reading and writing large 
sl@0
   107
amounts of blob or text data from a database.
sl@0
   108
sl@0
   109
@param aDatabase     A reference to the RSqlDatabase object that represents 
sl@0
   110
                     the database for which the SQL statement is being prepared.
sl@0
   111
@param aSqlStmt      A string of 8-bit wide characters containing the
sl@0
   112
                     SQL statement to be prepared.
sl@0
   113
sl@0
   114
sl@0
   115
@return KErrNone,     the SQL statement has been prepared for execution successfully;
sl@0
   116
        KErrNoMemory, an out of memory condition has occurred;
sl@0
   117
        KErrArgument, the SQL statement is invalid, for example, the supplied
sl@0
   118
                      string contains more than one SQL statement, or it
sl@0
   119
                      contains an empty SQL statement.
sl@0
   120
                      Note that database specific errors categorised as ESqlDbError
sl@0
   121
                      can also be returned;
sl@0
   122
        KSqlErrGeneral, a syntax error has occurred - text describing the problem
sl@0
   123
                        can be obtained by calling 	RSqlDatabase::LastErrorMessage().
sl@0
   124
		KErrPermissionDenied, the calling application does not satisfy the relevant database security policies.
sl@0
   125
                      Note that database specific errors categorised as ESqlDbError, and
sl@0
   126
                      other system-wide error codes may also be returned.
sl@0
   127
sl@0
   128
@capability None, if current RSqlStatement object represents a handle which operates on a non-secure database;
sl@0
   129
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement modifies a secure database schema; 
sl@0
   130
            RSqlSecurityPolicy::EReadPolicy or 
sl@0
   131
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement reads from a secure database; 
sl@0
   132
            RSqlSecurityPolicy::EWritePolicy or
sl@0
   133
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement writes to a secure database;
sl@0
   134
sl@0
   135
@see TSqlRetCodeClass::ESqlDbError
sl@0
   136
@see RSqlDatabase
sl@0
   137
@see RSqlDatabase::LastErrorMessage()
sl@0
   138
@see RSqlSecurityPolicy
sl@0
   139
@see RSqlSecurityPolicy::TPolicyType
sl@0
   140
@see RSqlBlobReadStream
sl@0
   141
@see RSqlBlobWriteStream
sl@0
   142
@see TSqlBlob
sl@0
   143
*/	
sl@0
   144
EXPORT_C TInt RSqlStatement::Prepare(RSqlDatabase& aDatabase, const TDesC8& aSqlStmt)
sl@0
   145
	{
sl@0
   146
	__SQLTRACE_BORDERVAR(TBuf<100> des16prnbuf);
sl@0
   147
    SQL_TRACE_BORDER(OstTraceExt3(TRACE_BORDER, RSQLSTATEMENT_PREPARE8_ENTRY, "Entry;0x%X;RSqlStatement::Prepare8;aDatabase=0x%X;aSqlStmt=%s", (TUint)this, (TUint)&aDatabase, __SQLPRNSTR8(aSqlStmt, des16prnbuf)));
sl@0
   148
	TInt err = CSqlStatementImpl::New(iImpl, aDatabase.Impl(), aSqlStmt);
sl@0
   149
    SQL_TRACE_BORDER(OstTraceExt3(TRACE_BORDER, RSQLSTATEMENT_PREPARE8_EXIT, "Exit;0x%X;RSqlStatement::Prepare8;iImpl=0x%X;err=%d", (TUint)this, (TUint)iImpl, err));
sl@0
   150
	return err;
sl@0
   151
	}
sl@0
   152
sl@0
   153
/**
sl@0
   154
Prepares the supplied 16-bit SQL statement for execution.
sl@0
   155
sl@0
   156
An RSqlStatement object can prepare and execute a parameterised SQL statement or
sl@0
   157
an SQL statement without parameters.
sl@0
   158
sl@0
   159
The function can only deal with one SQL statement at a time, i.e. if you
sl@0
   160
supply more than one SQL statement, each separated by a ";" character, then
sl@0
   161
the function returns an error.
sl@0
   162
sl@0
   163
Note that when the statement is to be used to retrieve or write blob or text data
sl@0
   164
that is over 2Mb in size then it is recommended that the RSqlBlobReadStream and 
sl@0
   165
RSqlBlobWriteStream classes or the TSqlBlob class is used instead. 
sl@0
   166
These classes provide a more RAM-efficient way of reading and writing large 
sl@0
   167
amounts of blob or text data from a database.
sl@0
   168
sl@0
   169
@param aDatabase     A reference to the RSqlDatabase object that represents 
sl@0
   170
                     the database for which the SQL statement is being prepared.
sl@0
   171
@param aSqlStmt      A string of 16-bit wide characters containing the
sl@0
   172
                     SQL statement to be prepared.
sl@0
   173
sl@0
   174
@leave  KErrNoMemory, an out of memory condition has occurred;
sl@0
   175
        KErrArgument, the SQL statement is invalid, for example, the supplied
sl@0
   176
                      string contains more than one SQL statement, or it
sl@0
   177
                      contains an empty SQL statement.
sl@0
   178
                      Note that database specific errors categorised as ESqlDbError
sl@0
   179
                      can also be returned;
sl@0
   180
        KSqlErrGeneral, a syntax error has occurred - text describing the problem
sl@0
   181
                        can be obtained by calling 	RSqlDatabase::LastErrorMessage().
sl@0
   182
		KErrPermissionDenied, the calling application does not satisfy the relevant database security policies.
sl@0
   183
                      Note that the function may leave with database specific errors categorised as ESqlDbError and
sl@0
   184
                      other system-wide error codes.
sl@0
   185
sl@0
   186
@capability None, if current RSqlStatement object represents a handle which operates on a non-secure database;
sl@0
   187
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement modifies a secure database schema; 
sl@0
   188
            RSqlSecurityPolicy::EReadPolicy or 
sl@0
   189
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement reads from a secure database; 
sl@0
   190
            RSqlSecurityPolicy::EWritePolicy or
sl@0
   191
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement writes to a secure database;
sl@0
   192
sl@0
   193
@see TSqlRetCodeClass::ESqlDbError
sl@0
   194
@see RSqlDatabase
sl@0
   195
@see RSqlDatabase::LastErrorMessage()
sl@0
   196
@see RSqlSecurityPolicy
sl@0
   197
@see RSqlSecurityPolicy::TPolicyType
sl@0
   198
@see RSqlBlobReadStream
sl@0
   199
@see RSqlBlobWriteStream
sl@0
   200
@see TSqlBlob
sl@0
   201
*/
sl@0
   202
EXPORT_C void RSqlStatement::PrepareL(RSqlDatabase& aDatabase, const TDesC& aSqlStmt)
sl@0
   203
	{
sl@0
   204
    SQL_TRACE_BORDER(OstTraceExt3(TRACE_BORDER, RSQLSTATEMENT_PREPARE16L_ENTRY, "Entry;0x%X;RSqlStatement::Prepare16L;aDatabase=0x%X;aSqlStmt=%S", (TUint)this, (TUint)&aDatabase, __SQLPRNSTR(aSqlStmt)));
sl@0
   205
	__SQLLEAVE_IF_ERROR(Prepare(aDatabase, aSqlStmt));
sl@0
   206
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_PREPARE16L_EXIT, "Exit;0x%X;RSqlStatement::Prepare16L;iImpl=0x%X", (TUint)this, (TUint)iImpl));
sl@0
   207
	}
sl@0
   208
	
sl@0
   209
/**
sl@0
   210
Prepares the supplied 8-bit SQL statement for execution.
sl@0
   211
sl@0
   212
An RSqlStatement object can prepare and execute a parameterised SQL statement or
sl@0
   213
an SQL statement without parameters.
sl@0
   214
sl@0
   215
The function can only deal with one SQL statement at a time, i.e. if you
sl@0
   216
supply more than one SQL statement, each separated by a ";" character, then
sl@0
   217
the function returns an error.
sl@0
   218
sl@0
   219
Note that when the statement is to be used to retrieve or write blob or text data
sl@0
   220
that is over 2Mb in size then it is recommended that the RSqlBlobReadStream and 
sl@0
   221
RSqlBlobWriteStream classes or the TSqlBlob class is used instead. 
sl@0
   222
These classes provide a more RAM-efficient way of reading and writing large 
sl@0
   223
amounts of blob or text data from a database.
sl@0
   224
sl@0
   225
@param aDatabase     A reference to the RSqlDatabase object that represents 
sl@0
   226
                     the database for which the SQL statement is being prepared.
sl@0
   227
@param aSqlStmt      A string of 8-bit wide characters containing the
sl@0
   228
                     SQL statement to be prepared.
sl@0
   229
sl@0
   230
sl@0
   231
@leave  KErrNoMemory, an out of memory condition has occurred;
sl@0
   232
        KErrArgument, the SQL statement is invalid, for example, the supplied
sl@0
   233
                      string contains more than one SQL statement, or it
sl@0
   234
                      contains an empty SQL statement.
sl@0
   235
                      Note that database specific errors categorised as ESqlDbError
sl@0
   236
                      can also be returned;
sl@0
   237
        KSqlErrGeneral, a syntax error has occurred - text describing the problem
sl@0
   238
                        can be obtained by calling 	RSqlDatabase::LastErrorMessage().
sl@0
   239
		KErrPermissionDenied, the calling application does not satisfy the relevant database security policies.
sl@0
   240
                      Note that the function may leave with database specific errors categorised as ESqlDbError and
sl@0
   241
                      other system-wide error codes.
sl@0
   242
sl@0
   243
@capability None, if current RSqlStatement object represents a handle which operates on a non-secure database;
sl@0
   244
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement modifies a secure database schema; 
sl@0
   245
            RSqlSecurityPolicy::EReadPolicy or 
sl@0
   246
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement reads from a secure database; 
sl@0
   247
            RSqlSecurityPolicy::EWritePolicy or
sl@0
   248
            RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement writes to a secure database;
sl@0
   249
sl@0
   250
@see TSqlRetCodeClass::ESqlDbError
sl@0
   251
@see RSqlDatabase
sl@0
   252
@see RSqlDatabase::LastErrorMessage()
sl@0
   253
@see RSqlSecurityPolicy
sl@0
   254
@see RSqlSecurityPolicy::TPolicyType
sl@0
   255
@see RSqlBlobReadStream
sl@0
   256
@see RSqlBlobWriteStream
sl@0
   257
@see TSqlBlob
sl@0
   258
*/
sl@0
   259
EXPORT_C void RSqlStatement::PrepareL(RSqlDatabase& aDatabase, const TDesC8& aSqlStmt)
sl@0
   260
	{
sl@0
   261
	__SQLTRACE_BORDERVAR(TBuf<100> des16prnbuf);
sl@0
   262
    SQL_TRACE_BORDER(OstTraceExt3(TRACE_BORDER, RSQLSTATEMENT_PREPARE8L_ENTRY, "Entry;0x%X;RSqlStatement::Prepare8L;aDatabase=0x%X;aSqlStmt=%s", (TUint)this, (TUint)&aDatabase, __SQLPRNSTR8(aSqlStmt, des16prnbuf)));
sl@0
   263
	__SQLLEAVE_IF_ERROR(Prepare(aDatabase, aSqlStmt));
sl@0
   264
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_PREPARE8L_EXIT, "Exit;0x%X;RSqlStatement::Prepare8L;iImpl=0x%X", (TUint)this, (TUint)iImpl));
sl@0
   265
	}
sl@0
   266
sl@0
   267
sl@0
   268
/**
sl@0
   269
Closes this SQL statement object.
sl@0
   270
sl@0
   271
The function frees memory and any allocated resources.
sl@0
   272
sl@0
   273
@see RSqlStatement::Prepare()
sl@0
   274
sl@0
   275
@capability None
sl@0
   276
*/	
sl@0
   277
EXPORT_C void RSqlStatement::Close()
sl@0
   278
	{
sl@0
   279
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_CLOSE_ENTRY, "Entry;0x%X;RSqlStatement::Close;iImpl=0x%X", (TUint)this, (TUint)iImpl));
sl@0
   280
	delete iImpl;
sl@0
   281
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_CLOSE_EXIT, "Exit;0x%X;RSqlStatement::Close;iImpl=0x%X", (TUint)this, (TUint)iImpl));
sl@0
   282
	iImpl = NULL;
sl@0
   283
	}
sl@0
   284
sl@0
   285
/**
sl@0
   286
Tests whether the SQL statement points to a valid record.
sl@0
   287
sl@0
   288
@return True, if the SQL statement points to a valid record, false otherwise.
sl@0
   289
sl@0
   290
@capability None
sl@0
   291
*/
sl@0
   292
EXPORT_C TBool RSqlStatement::AtRow() const
sl@0
   293
	{
sl@0
   294
	return Impl().AtRow();
sl@0
   295
	}
sl@0
   296
	
sl@0
   297
/**
sl@0
   298
Resets the prepared SQL statement to its initial state and makes it ready to be
sl@0
   299
executed again.
sl@0
   300
sl@0
   301
Any SQL statement parameters that had values bound to them, retain their values.
sl@0
   302
sl@0
   303
If this object processes a parameterised SQL statement, then the parameter
sl@0
   304
values can be bound after the call to Reset().
sl@0
   305
sl@0
   306
If the call to this function fails because of a database-specific type error 
sl@0
   307
(i.e. the error is categorised as of type ESqlDbError), then a textual description of
sl@0
   308
the error can be obtained calling RSqlDatabase::LastErrorMessage().
sl@0
   309
sl@0
   310
sl@0
   311
Usage pattern 1:
sl@0
   312
sl@0
   313
@code
sl@0
   314
RSqlStatement stmt;
sl@0
   315
TInt err = stmt.Prepare(<database>, <SQL statement>);
sl@0
   316
while(<condition>)
sl@0
   317
	{
sl@0
   318
	err = stmt.Bind<parameter type>(<parameter index>, <value>);
sl@0
   319
	...
sl@0
   320
	err = stmt.Exec();
sl@0
   321
	....
sl@0
   322
	err = stmt.Reset();
sl@0
   323
	}
sl@0
   324
stmt.Close();
sl@0
   325
@endcode
sl@0
   326
sl@0
   327
Usage pattern 2:
sl@0
   328
sl@0
   329
@code
sl@0
   330
RSqlStatement stmt;
sl@0
   331
TInt err = stmt.Prepare(<database>, <SQL statement>);
sl@0
   332
while(<condition>)
sl@0
   333
	{
sl@0
   334
	err = stmt.Bind<parameter type>(<parameter index>, <value>);
sl@0
   335
	...
sl@0
   336
	while((err = stmt.Next()) == KSqlAtRow)
sl@0
   337
		{
sl@0
   338
		....
sl@0
   339
		}
sl@0
   340
	err = stmt.Reset();
sl@0
   341
	}
sl@0
   342
stmt.Close();
sl@0
   343
@endcode
sl@0
   344
sl@0
   345
@return KErrNone, the reset operation has completed successfully;			
sl@0
   346
        KSqlErrStmtExpired, the SQL statement has expired (if new functions or
sl@0
   347
                            collating sequences have been registered or if an
sl@0
   348
                            authorizer function has been added or changed)
sl@0
   349
sl@0
   350
@see TSqlRetCodeClass::ESqlDbError
sl@0
   351
@see RSqlDatabase::LastErrorMessage()
sl@0
   352
sl@0
   353
@capability None
sl@0
   354
*/	
sl@0
   355
EXPORT_C TInt RSqlStatement::Reset()
sl@0
   356
	{
sl@0
   357
    SQL_TRACE_BORDER(OstTrace1(TRACE_BORDER, RSQLSTATEMENT_RESET_ENTRY, "Entry;0x%X;RSqlStatement::Reset", (TUint)this));
sl@0
   358
	TInt err = Impl().Reset();
sl@0
   359
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_RESET_EXIT, "Exit;0x%X;RSqlStatement::Reset;err=%d", (TUint)this, err));
sl@0
   360
	return err;
sl@0
   361
	}
sl@0
   362
	
sl@0
   363
/**
sl@0
   364
Executes the prepared DDL/DML SQL statement. 
sl@0
   365
sl@0
   366
The function is very useful when the SQL statement contains parameters, because
sl@0
   367
the statement can be prepared once using RSqlStatement::Prepare(), and then
sl@0
   368
bound and executed many times.
sl@0
   369
sl@0
   370
Note that:
sl@0
   371
- parameter values must be bound before calling Exec().
sl@0
   372
- SQL statements that do not have parameters should use RSqlDatabase::Exec() instead.
sl@0
   373
sl@0
   374
If the call to this function fails because of a database-specific type error 
sl@0
   375
(i.e. the error is categorised as of type ESqlDbError), then a textual description of
sl@0
   376
the error can be obtained calling RSqlDatabase::LastErrorMessage().
sl@0
   377
sl@0
   378
Usage pattern:
sl@0
   379
sl@0
   380
@code
sl@0
   381
RSqlStatement stmt;
sl@0
   382
TInt err = stmt.Prepare(<database>, <SQL statement>);
sl@0
   383
while(<condition>)
sl@0
   384
	{
sl@0
   385
	err = stmt.Bind<parameter type>(<parameter index>, <value>);
sl@0
   386
	...
sl@0
   387
	err = stmt.Exec();
sl@0
   388
	....
sl@0
   389
	err = stmt.Reset();
sl@0
   390
	}
sl@0
   391
stmt.Close();
sl@0
   392
@endcode
sl@0
   393
sl@0
   394
@return >=0, The operation has completed successfully. The number of database rows that were 
sl@0
   395
			 changed/inserted/deleted by the most recently completed DDL/DML sql statement.
sl@0
   396
			 Exception: If the executed statement is "DELETE FROM <table>", then the function returns 0 
sl@0
   397
			 if the operation has completed successfully (disregarding the number of the deleted rows);
sl@0
   398
        KSqlErrStmtExpired, the SQL statement has expired (if new functions or
sl@0
   399
                            collating sequences have been registered or if an
sl@0
   400
                            authorizer function has been added or changed);
sl@0
   401
    	KErrDiskFull, There is no available disk space to complete the operation. If the executed statement is a DELETE
sl@0
   402
    			  statement, try to use the reserved disk space (if there is a reserved disk space) to complete the operation.
sl@0
   403
    			  In all other cases the statement and database connection should be closed and some disk space freed 
sl@0
   404
    			  before reopening the database; 
sl@0
   405
        KErrNoMemory, an out of memory condition has occurred - the statement
sl@0
   406
                      will be reset.
sl@0
   407
                      Note that database specific errors categorised as ESqlDbError
sl@0
   408
                      can also be returned.
sl@0
   409
sl@0
   410
@see TSqlRetCodeClass::ESqlDbError
sl@0
   411
@see RSqlStatement::Prepare()
sl@0
   412
@see RSqlDatabase::Exec()
sl@0
   413
@see RSqlDatabase::LastErrorMessage()
sl@0
   414
sl@0
   415
@capability None
sl@0
   416
*/	
sl@0
   417
EXPORT_C TInt RSqlStatement::Exec()
sl@0
   418
	{
sl@0
   419
    SQL_TRACE_BORDER(OstTrace1(TRACE_BORDER, RSQLSTATEMENT_EXEC_ENTRY, "Entry;0x%X;RSqlStatement::Exec", (TUint)this));
sl@0
   420
	TInt err = Impl().Exec();
sl@0
   421
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_EXEC_EXIT, "Exit;0x%X;RSqlStatement::Exec;err=%d", (TUint)this, err));
sl@0
   422
	return err;
sl@0
   423
	}
sl@0
   424
sl@0
   425
/**
sl@0
   426
Executes the prepared DDL/DML SQL statement asynchronously to allow client to avoid being blocked 
sl@0
   427
by server activity.
sl@0
   428
sl@0
   429
No other operations can be performed on current RSqlStatement object 
sl@0
   430
until the asynchronous operation completes.
sl@0
   431
sl@0
   432
The function is very useful when the SQL statement contains parameters, because
sl@0
   433
the statement can be prepared once using RSqlStatement::Prepare(), and then
sl@0
   434
bound and executed many times.
sl@0
   435
sl@0
   436
Note that:
sl@0
   437
- parameter values must be bound before calling Exec().
sl@0
   438
- SQL statements that do not have parameters should use RSqlDatabase::Exec() instead.
sl@0
   439
sl@0
   440
If the call to this function fails because of a database-specific type error 
sl@0
   441
(i.e. the error is categorised as of type ESqlDbError), then a textual description of
sl@0
   442
the error can be obtained calling RSqlDatabase::LastErrorMessage().
sl@0
   443
sl@0
   444
@param aStatus Completion status of asynchronous request, one of the following:
sl@0
   445
	>=0, The operation has completed successfully. The number of database rows that were 
sl@0
   446
		changed/inserted/deleted by the most recently completed DDL/DML sql statement.
sl@0
   447
		Exception: If the executed statement is "DELETE FROM <table>", then the function returns 0 
sl@0
   448
		if the operation has completed successfully (disregarding the number of the deleted rows);
sl@0
   449
	KSqlErrStmtExpired, the SQL statement has expired (if new functions or 
sl@0
   450
						collating sequences have been registered or if an 
sl@0
   451
						authorizer function has been added or changed);
sl@0
   452
	KErrDiskFull, There is no available disk space to complete the operation. If the executed statement is a DELETE 
sl@0
   453
				statement, try to use the reserved disk space (if there is a reserved disk space) 
sl@0
   454
				to complete the operation.
sl@0
   455
				In all other cases the statement and database connection should be closed and some disk space freed 
sl@0
   456
				before reopening the database; 
sl@0
   457
	KErrNoMemory, an out of memory condition has occurred - the statement 
sl@0
   458
	will be reset.
sl@0
   459
	Note that aStatus may be set with database specific errors categorised as ESqlDbError,
sl@0
   460
	and other system-wide error codes.
sl@0
   461
sl@0
   462
sl@0
   463
@see TSqlRetCodeClass::ESqlDbError
sl@0
   464
@see RSqlStatement::Prepare()
sl@0
   465
@see RSqlDatabase::Exec()
sl@0
   466
@see RSqlDatabase::LastErrorMessage()
sl@0
   467
sl@0
   468
@capability None
sl@0
   469
*/	
sl@0
   470
EXPORT_C void RSqlStatement::Exec(TRequestStatus& aStatus)
sl@0
   471
	{
sl@0
   472
    SQL_TRACE_BORDER(OstTrace1(TRACE_BORDER, RSQLSTATEMENT_EXECASYNC_ENTRY, "Entry;0x%X;RSqlStatement::ExecAsync", (TUint)this));
sl@0
   473
	Impl().Exec(aStatus);
sl@0
   474
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_EXECASYNC_EXIT, "Exit;0x%X;RSqlStatement::ExecAsync;aStatus.Int()=%d", (TUint)this, aStatus.Int()));
sl@0
   475
	}
sl@0
   476
	
sl@0
   477
/**
sl@0
   478
Retrieves a record.
sl@0
   479
sl@0
   480
If the prepared SQL statement is a "SELECT" statement, and is expected to
sl@0
   481
return a set of records, then this function can be used to retrieve that record data.
sl@0
   482
sl@0
   483
If the SQL statement contains parameters, then their values must be bound before
sl@0
   484
this function is called.
sl@0
   485
sl@0
   486
If the call to this function completes successfully, i.e. it returns
sl@0
   487
with KSqlAtRow, then this RSqlStatement object contains the record data, and 
sl@0
   488
this data will remain valid for access until another call is made to any
sl@0
   489
RSqlStatement function.
sl@0
   490
sl@0
   491
The record data can be accessed using the following functions:
sl@0
   492
- RSqlStatement::ColumnType()
sl@0
   493
- RSqlStatement::ColumnSize()
sl@0
   494
- RSqlStatement::ColumnInt()
sl@0
   495
- RSqlStatement::ColumnInt64()
sl@0
   496
- RSqlStatement::ColumnReal()
sl@0
   497
- RSqlStatement::ColumnTextL()
sl@0
   498
- RSqlStatement::ColumnText()
sl@0
   499
- RSqlStatement::ColumnBinary()
sl@0
   500
- RSqlStatement::ColumnBinaryL()
sl@0
   501
sl@0
   502
Note that if this call to Next() fails, as indicated by a return code value
sl@0
   503
other than KSqlAtRow, then calls to these RSqlStatement::Column...() functions
sl@0
   504
will raise a panic.
sl@0
   505
sl@0
   506
@return KSqlAtRow,      the record data is ready for processing by the caller;
sl@0
   507
        KSqlAtEnd,      there is no more record data;
sl@0
   508
        KSqlErrBusy,    the database file is locked;
sl@0
   509
        KErrNoMemory,   an out of memory condition has occurred - the statement
sl@0
   510
                        will be reset;
sl@0
   511
        KSqlErrGeneral, a run-time error has occured - this function must not
sl@0
   512
                        be called again;        
sl@0
   513
        KSqlErrMisuse,  this function has been called after a previous call
sl@0
   514
                        returned KSqlAtEnd or KSqlErrGeneral.
sl@0
   515
        KSqlErrStmtExpired, the SQL statement has expired (if new functions or
sl@0
   516
                            collating sequences have been registered or if an
sl@0
   517
                            authorizer function has been added or changed);
sl@0
   518
sl@0
   519
@capability None
sl@0
   520
*/	
sl@0
   521
EXPORT_C TInt RSqlStatement::Next()
sl@0
   522
	{
sl@0
   523
    SQL_TRACE_BORDER(OstTrace1(TRACE_BORDER, RSQLSTATEMENT_NEXT_ENTRY, "Entry;0x%X;RSqlStatement::Next", (TUint)this));
sl@0
   524
	TInt err = Impl().Next();
sl@0
   525
    SQL_TRACE_BORDER(OstTraceExt2(TRACE_BORDER, RSQLSTATEMENT_NEXT_EXIT, "Exit;0x%X;RSqlStatement::Next;err=%d", (TUint)this, err));
sl@0
   526
	return err;
sl@0
   527
	}
sl@0
   528
sl@0
   529
/**
sl@0
   530
Gets the index (starting from 0) of the parameter with the given name.
sl@0
   531
sl@0
   532
The function does a case insensitive parameter name search.
sl@0
   533
sl@0
   534
For example, if the parameter name is ":Prm", then the ":" prefix cannot
sl@0
   535
be omitted when you call ParameterIndex().
sl@0
   536
sl@0
   537
This function can be called at any time after the SQL statement has been prepared.
sl@0
   538
sl@0
   539
@param aParameterName The parameter name.
sl@0
   540
sl@0
   541
@return the parameter index value, if successful - this is a non-negative integer value;
sl@0
   542
        KErrNotFound, if no such parameter can be found.
sl@0
   543
        One of the other system-wide error codes may also be returned.
sl@0
   544
sl@0
   545
@capability None
sl@0
   546
*/	
sl@0
   547
EXPORT_C TInt RSqlStatement::ParameterIndex(const TDesC& aParameterName) const
sl@0
   548
	{
sl@0
   549
	return Impl().ParamIndex(aParameterName);
sl@0
   550
	}
sl@0
   551
sl@0
   552
/**
sl@0
   553
Gets the number of columns that are to be returned by this SQL statement.
sl@0
   554
sl@0
   555
This function can be called at any time after the SQL statement has been prepared,
sl@0
   556
but it is useful only for SELECT statements. The column count of any other type of statement is always 0.
sl@0
   557
sl@0
   558
@return The number of columns.
sl@0
   559
sl@0
   560
@capability None
sl@0
   561
*/	
sl@0
   562
EXPORT_C TInt RSqlStatement::ColumnCount() const
sl@0
   563
	{
sl@0
   564
	return Impl().ColumnCount();
sl@0
   565
	}
sl@0
   566
	
sl@0
   567
/**
sl@0
   568
Gets the index (starting from 0) of the column with the given name.
sl@0
   569
sl@0
   570
The function does a case insensitive column name search.
sl@0
   571
sl@0
   572
This function can be called at any time after the SQL statement has been prepared.
sl@0
   573
sl@0
   574
@param aColumnName The column name.
sl@0
   575
sl@0
   576
@return the column index value, if successful - this is a non-negative integer value;
sl@0
   577
        KErrNotFound, if no such parameter can be found.
sl@0
   578
        One of the other system-wide error codes may also be returned.
sl@0
   579
sl@0
   580
@capability None
sl@0
   581
*/	
sl@0
   582
EXPORT_C TInt RSqlStatement::ColumnIndex(const TDesC& aColumnName) const
sl@0
   583
	{
sl@0
   584
	return Impl().ColumnIndex(aColumnName);
sl@0
   585
	}
sl@0
   586
	
sl@0
   587
/**
sl@0
   588
Gets the runtime type of the column identified by the specified column index.
sl@0
   589
sl@0
   590
This function returns the actual runtime datatype of the specified column as 
sl@0
   591
opposed to its declared type.
sl@0
   592
  
sl@0
   593
Note that the function can only be called after a successful call to Next(),
sl@0
   594
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
   595
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
   596
sl@0
   597
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
   598
sl@0
   599
@return The column type.
sl@0
   600
sl@0
   601
@see KSqlAtRow
sl@0
   602
@see TSqlColumnType
sl@0
   603
@see RSqlStatement::DeclaredColumnType()
sl@0
   604
@see RSqlStatement::Next()
sl@0
   605
@see RSqlStatement::ColumnIndex()
sl@0
   606
sl@0
   607
@panic SqlDb 5 Column index out of bounds.
sl@0
   608
@panic SqlDb 11 Statement cursor not positioned on a row.
sl@0
   609
sl@0
   610
@capability None
sl@0
   611
*/	
sl@0
   612
EXPORT_C TSqlColumnType RSqlStatement::ColumnType(TInt aColumnIndex) const
sl@0
   613
	{
sl@0
   614
	return Impl().ColumnType(aColumnIndex);
sl@0
   615
	}
sl@0
   616
sl@0
   617
/**
sl@0
   618
Gets the declared type of the column identified by the specified column index.
sl@0
   619
sl@0
   620
Note that the function can only be called when executing a SELECT query, and 
sl@0
   621
only after a successful call to Prepare(). 
sl@0
   622
sl@0
   623
This function returns the datatype that the specified column was originally declared to have.
sl@0
   624
sl@0
   625
The declared type of a column is determined according to the following rules:
sl@0
   626
@code
sl@0
   627
 - if the column type name contains the string "INT", then the declared column type is ESqlInt;
sl@0
   628
 - if the column type name contains any of the strings "CHAR, "TEXT" or "CLOB", then the declared column type is ESqlText;
sl@0
   629
 - if the column type name contains any of the strings "BLOB" or "BINARY", then the declared column type is ESqlBinary;
sl@0
   630
 - if the column type name contains any of the strings "FLOAT", "REAL" or "DOUBLE", then the declared column type is ESqlReal;
sl@0
   631
 - in all other cases the declared column type is assumed to be ESqlInt;
sl@0
   632
@endcode
sl@0
   633
sl@0
   634
@param aColumnIndex The index value identifying the column. This is 0 for the first column.
sl@0
   635
@param aColumnType	Output parameter. If the call completes successfully, aColumnType contains the type of the column, one of
sl@0
   636
					TSqlColumnType enum item values.
sl@0
   637
sl@0
   638
@return KErrNone, the operation completed successfully;
sl@0
   639
        KErrNoMemory, an out of memory condition has occurred.
sl@0
   640
                  One of the other system-wide error codes may also be returned.
sl@0
   641
sl@0
   642
@see TSqlColumnType
sl@0
   643
@see RSqlStatement::ColumnType()
sl@0
   644
@see RSqlStatement::ColumnIndex()
sl@0
   645
sl@0
   646
@panic SqlDb 5 Column index out of bounds.
sl@0
   647
sl@0
   648
@capability None
sl@0
   649
*/	
sl@0
   650
EXPORT_C TInt RSqlStatement::DeclaredColumnType(TInt aColumnIndex, TSqlColumnType& aColumnType) const
sl@0
   651
	{
sl@0
   652
	return Impl().DeclaredColumnType(aColumnIndex, aColumnType);
sl@0
   653
	}
sl@0
   654
	
sl@0
   655
	
sl@0
   656
	
sl@0
   657
/**
sl@0
   658
Gets the length of the data for the column identified by the specified column index.
sl@0
   659
sl@0
   660
The length depends on the column type and is normally in bytes, except for
sl@0
   661
the case where the column type is ESqlText, in which case the function returns
sl@0
   662
the number of characters.
sl@0
   663
sl@0
   664
In detail, the following table shows the size associated with a column type.
sl@0
   665
Note that column types are identified by TSqlColumnType enum values.
sl@0
   666
@code
sl@0
   667
--------------------------------------------------------------
sl@0
   668
| Column type | Column Size                                 
sl@0
   669
--------------------------------------------------------------
sl@0
   670
| ESqlInt.....|.4                                             
sl@0
   671
| ESqlInt64...|.8                                             
sl@0
   672
| ESqlReal....|.8                                             
sl@0
   673
| ESqlText....|.the number of characters in the unicode string
sl@0
   674
| ESqlBinary..|.the byte length of the binary data            
sl@0
   675
| ESqlNull....|.0                                             
sl@0
   676
--------------------------------------------------------------
sl@0
   677
@endcode
sl@0
   678
sl@0
   679
Note that the function can only be called after a successful call to Next(),
sl@0
   680
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
   681
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
   682
sl@0
   683
@param aColumnIndex The column index value; this is 0 for the first column.
sl@0
   684
sl@0
   685
@return The size of the column, and depends on the type of column.
sl@0
   686
sl@0
   687
@see KSqlAtRow
sl@0
   688
@see TSqlColumnType
sl@0
   689
@see RSqlStatement::Next()
sl@0
   690
@see RSqlStatement::ColumnIndex()                
sl@0
   691
sl@0
   692
@panic SqlDb 5 Column index out of bounds.
sl@0
   693
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
   694
sl@0
   695
@capability None
sl@0
   696
*/	
sl@0
   697
EXPORT_C TInt RSqlStatement::ColumnSize(TInt aColumnIndex) const
sl@0
   698
	{
sl@0
   699
	return Impl().ColumnSize(aColumnIndex);
sl@0
   700
	}
sl@0
   701
sl@0
   702
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   703
///////////////////////////          Bind<Type>() implemenations           /////////////////////////////
sl@0
   704
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   705
sl@0
   706
/**
sl@0
   707
Sets the parameter to a NULL value.
sl@0
   708
sl@0
   709
The parameter is identified by the specified index value.
sl@0
   710
sl@0
   711
A parameter value can be set:
sl@0
   712
- immediately after this SQL statement has been prepared
sl@0
   713
- after a call to Reset()
sl@0
   714
sl@0
   715
@param aParamIndex The index value identifying the parameter; this is 0 for the first parameter.
sl@0
   716
sl@0
   717
@return KErrNone, the operation completed successfully.
sl@0
   718
                  One of the other system-wide error codes may also be returned.
sl@0
   719
sl@0
   720
@see RSqlStatement::Prepare()
sl@0
   721
@see RSqlStatement::Reset()                
sl@0
   722
sl@0
   723
@panic SqlDb 5 Parameter index out of bounds.
sl@0
   724
sl@0
   725
@capability None
sl@0
   726
*/	
sl@0
   727
EXPORT_C TInt RSqlStatement::BindNull(TInt aParamIndex)
sl@0
   728
	{
sl@0
   729
	return Impl().BindNull(aParamIndex);
sl@0
   730
	}
sl@0
   731
	
sl@0
   732
/**
sl@0
   733
Sets the parameter to the specified 32-bit integer value.
sl@0
   734
sl@0
   735
The parameter is identified by the specified index value.
sl@0
   736
sl@0
   737
A parameter value can be set:
sl@0
   738
- immediately after this SQL statement has been prepared
sl@0
   739
- after a call to Reset()
sl@0
   740
sl@0
   741
@param aParamIndex The index value identifying the parameter; this is 0 for the first parameter.
sl@0
   742
@param aParamValue The 32-bit integer value to be assigned to the parameter.
sl@0
   743
sl@0
   744
@return KErrNone, the operation completed successfully;
sl@0
   745
        KErrNoMemory, an out of memory condition has occurred.
sl@0
   746
                  One of the other system-wide error codes may also be returned.
sl@0
   747
sl@0
   748
@see RSqlStatement::Prepare()
sl@0
   749
@see RSqlStatement::Reset()                
sl@0
   750
sl@0
   751
@panic SqlDb 5 Parameter index out of bounds.
sl@0
   752
sl@0
   753
@capability None
sl@0
   754
*/	
sl@0
   755
EXPORT_C TInt RSqlStatement::BindInt(TInt aParamIndex, TInt aParamValue)
sl@0
   756
	{
sl@0
   757
	return Impl().BindInt(aParamIndex, aParamValue);
sl@0
   758
	}
sl@0
   759
	
sl@0
   760
/**
sl@0
   761
Sets the parameter to the specified 64-bit integer value.
sl@0
   762
sl@0
   763
The parameter is identified by the specified index value.
sl@0
   764
sl@0
   765
A parameter value can be set:
sl@0
   766
- immediately after this SQL statement has been prepared
sl@0
   767
- after a call to Reset()
sl@0
   768
sl@0
   769
@param aParamIndex The index value identifying the parameter; this is 0 for the first parameter.
sl@0
   770
@param aParamValue The 64-bit integer value to be assigned to the parameter.
sl@0
   771
sl@0
   772
@return KErrNone, the operation completed successfully;
sl@0
   773
        KErrNoMemory, an out of memory condition has occurred.
sl@0
   774
                  One of the other system-wide error codes may also be returned.
sl@0
   775
sl@0
   776
@see RSqlStatement::Prepare()
sl@0
   777
@see RSqlStatement::Reset()                
sl@0
   778
sl@0
   779
@panic SqlDb 5 Parameter index out of bounds.
sl@0
   780
sl@0
   781
@capability None
sl@0
   782
*/	
sl@0
   783
EXPORT_C TInt RSqlStatement::BindInt64(TInt aParamIndex, TInt64 aParamValue)
sl@0
   784
	{
sl@0
   785
	return Impl().BindInt64(aParamIndex, aParamValue);
sl@0
   786
	}
sl@0
   787
	
sl@0
   788
/**
sl@0
   789
Sets the parameter to the specified 64-bit floating point value.
sl@0
   790
sl@0
   791
The parameter is identified by the specified index value.
sl@0
   792
sl@0
   793
A parameter value can be set:
sl@0
   794
- immediately after this SQL statement has been prepared
sl@0
   795
- after a call to Reset()
sl@0
   796
sl@0
   797
@param aParamIndex The index value identifying the parameter; this is 0 for the first parameter.
sl@0
   798
@param aParamValue The 64-bit floating point value to be assigned to the parameter.
sl@0
   799
sl@0
   800
@return KErrNone, the operation completed successfully;
sl@0
   801
        KErrNoMemory, an out of memory condition has occurred.
sl@0
   802
                  One of the other system-wide error codes may also be returned.
sl@0
   803
sl@0
   804
@see RSqlStatement::Prepare()
sl@0
   805
@see RSqlStatement::Reset()                
sl@0
   806
sl@0
   807
@panic SqlDb 5 Parameter index out of bounds.
sl@0
   808
sl@0
   809
@capability None
sl@0
   810
*/	
sl@0
   811
EXPORT_C TInt RSqlStatement::BindReal(TInt aParamIndex, TReal aParamValue)
sl@0
   812
	{
sl@0
   813
	return Impl().BindReal(aParamIndex, aParamValue);
sl@0
   814
	}
sl@0
   815
	
sl@0
   816
/**
sl@0
   817
Sets the parameter to the specified 16-bit descriptor.
sl@0
   818
sl@0
   819
The parameter is identified by the specified index value.
sl@0
   820
sl@0
   821
A parameter value can be set:
sl@0
   822
- immediately after this SQL statement has been prepared
sl@0
   823
- after a call to Reset()
sl@0
   824
sl@0
   825
Note that when the text data to be bound is over 2Mb in size then 
sl@0
   826
use of the RSqlBlobWriteStream or TSqlBlob class should be considered instead. 
sl@0
   827
sl@0
   828
These classes provide a more RAM-efficient way of writing large amounts of
sl@0
   829
text data to a database, however no conversions are performed on the text data -
sl@0
   830
it is simply stored as a stream of bytes. If the text data is part of a record 
sl@0
   831
to be inserted into a database then BindZeroBlob() should be called on the 
sl@0
   832
INSERT statement to create a placeholder for the text data, whose content 
sl@0
   833
can then be written using the above classes.
sl@0
   834
sl@0
   835
@param aParamIndex The index value identifying the parameter; this is 0 for the first parameter.
sl@0
   836
@param aParamText  The 16-bit descriptor whose content is to be assigned to the parameter.
sl@0
   837
sl@0
   838
@return KErrNone, the operation completed successfully;
sl@0
   839
        KErrNoMemory, an out of memory condition has occurred.
sl@0
   840
                  One of the other system-wide error codes may also be returned.
sl@0
   841
sl@0
   842
@see RSqlStatement::Prepare()
sl@0
   843
@see RSqlStatement::Reset()
sl@0
   844
@see RSqlStatement::Next()                
sl@0
   845
@see RSqlStatement::Exec()  
sl@0
   846
@see RSqlStatement::BindZeroBlob()  
sl@0
   847
@see RSqlBlobWriteStream
sl@0
   848
@see TSqlBlob  
sl@0
   849
sl@0
   850
@panic SqlDb 5 Parameter index out of bounds.
sl@0
   851
sl@0
   852
@capability None
sl@0
   853
*/	
sl@0
   854
EXPORT_C TInt RSqlStatement::BindText(TInt aParamIndex, const TDesC& aParamText)
sl@0
   855
	{
sl@0
   856
	return Impl().BindText(aParamIndex, aParamText);
sl@0
   857
	}
sl@0
   858
	
sl@0
   859
/**
sl@0
   860
Sets the parameter to the specified 8-bit descriptor.
sl@0
   861
sl@0
   862
The parameter is identified by the specified index value.
sl@0
   863
sl@0
   864
A parameter value can be set:
sl@0
   865
- immediately after this SQL statement has been prepared
sl@0
   866
- after a call to Reset()
sl@0
   867
sl@0
   868
Note that when the binary data to be bound is over 2Mb in size then it is 
sl@0
   869
recommended that the RSqlBlobWriteStream or TSqlBlob class is used instead. 
sl@0
   870
sl@0
   871
These classes provide a more RAM-efficient way of writing large amounts of
sl@0
   872
binary data to a database. If the binary data is part of a record to be inserted 
sl@0
   873
into a database then BindZeroBlob() should be called on the INSERT statement to create
sl@0
   874
a placeholder for the binary data, whose content can then be written using the above classes.
sl@0
   875
sl@0
   876
@param aParamIndex The index value identifying the parameter; this is 0 for the first parameter.
sl@0
   877
@param aParamData  The 8-bit descriptor whose content is to be assigned to the parameter.
sl@0
   878
sl@0
   879
@return KErrNone, the operation completed successfully;
sl@0
   880
        KErrNoMemory, an out of memory condition has occurred.
sl@0
   881
                  One of the other system-wide error codes may also be returned.
sl@0
   882
sl@0
   883
@see RSqlStatement::Prepare()
sl@0
   884
@see RSqlStatement::Reset()
sl@0
   885
@see RSqlStatement::Next()                
sl@0
   886
@see RSqlStatement::Exec()
sl@0
   887
@see RSqlStatement::BindZeroBlob()  
sl@0
   888
@see RSqlBlobWriteStream
sl@0
   889
@see TSqlBlob  
sl@0
   890
sl@0
   891
@panic SqlDb 5 Parameter index out of bounds.
sl@0
   892
sl@0
   893
@capability None
sl@0
   894
*/	
sl@0
   895
EXPORT_C TInt RSqlStatement::BindBinary(TInt aParamIndex, const TDesC8& aParamData)
sl@0
   896
	{
sl@0
   897
	return Impl().BindBinary(aParamIndex, aParamData);
sl@0
   898
	}
sl@0
   899
	
sl@0
   900
/**
sl@0
   901
Binds a blob of length aBlobSize bytes that is filled with zeroes.
sl@0
   902
sl@0
   903
The parameter is identified by the specified index value.
sl@0
   904
sl@0
   905
A parameter value can be set:
sl@0
   906
- immediately after this SQL statement has been prepared
sl@0
   907
- after a call to Reset()
sl@0
   908
sl@0
   909
A zeroblob acts as a placeholder for a blob whose binary content is later written
sl@0
   910
using the RSqlBlobWriteStream or TSqlBlob class. 
sl@0
   911
sl@0
   912
Using zeroblobs provides a much more RAM-efficient way of creating large blobs than 
sl@0
   913
including the blob data in the INSERT statement and it is recommended for blobs that
sl@0
   914
are over 2Mb in size.
sl@0
   915
sl@0
   916
Note that a zeroblob should be created in a column after which there are no columns 
sl@0
   917
that contain anything other than zeroblobs or NULLs, otherwise the zeroblob must be 
sl@0
   918
allocated in full in RAM and its benefit is lost.
sl@0
   919
sl@0
   920
When creating a zeroblob it is recommended, where possible, to create the zeroblob 
sl@0
   921
and then write the blob content (using the RSqlBlobWriteStream or TSqlBlob class) 
sl@0
   922
within the same transaction. Otherwise the zeroblob will have to be journalled 
sl@0
   923
before being written to.
sl@0
   924
sl@0
   925
@param aParamIndex The index value identifying the parameter; this is 0 for the first parameter.
sl@0
   926
@param aBlobSize  The size in bytes of the blob.
sl@0
   927
sl@0
   928
@return KErrNone, the operation completed successfully;
sl@0
   929
        KErrNoMemory, an out of memory condition has occurred.
sl@0
   930
                  One of the other system-wide error codes may also be returned.
sl@0
   931
sl@0
   932
@see RSqlStatement::Prepare()
sl@0
   933
@see RSqlStatement::Reset()
sl@0
   934
@see RSqlStatement::Next()                
sl@0
   935
@see RSqlStatement::Exec()   
sl@0
   936
@see RSqlBlobWriteStream
sl@0
   937
@see TSqlBlob 
sl@0
   938
sl@0
   939
@panic SqlDb 5 Parameter index out of bounds.
sl@0
   940
sl@0
   941
@capability None
sl@0
   942
*/	
sl@0
   943
EXPORT_C TInt RSqlStatement::BindZeroBlob(TInt aParamIndex, TInt aBlobSize)
sl@0
   944
	{
sl@0
   945
	return Impl().BindZeroBlob(aParamIndex, aBlobSize);
sl@0
   946
	}
sl@0
   947
sl@0
   948
sl@0
   949
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   950
///////////////////////////          Column<Type>() implemenations           ///////////////////////////
sl@0
   951
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   952
sl@0
   953
/**
sl@0
   954
Tests whether the value of the specified column is NULL.
sl@0
   955
sl@0
   956
The column is identified by the specified index value.
sl@0
   957
sl@0
   958
Note that the function can only be called after a successful call to Next(),
sl@0
   959
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
   960
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
   961
sl@0
   962
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
   963
sl@0
   964
@return True, if the value of the column is NULL, false otherwise.
sl@0
   965
sl@0
   966
@see KSqlAtRow
sl@0
   967
@see RSqlStatement::Prepare()
sl@0
   968
@see RSqlStatement::Next()                
sl@0
   969
sl@0
   970
@panic SqlDb 5 Column index out of bounds.
sl@0
   971
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
   972
sl@0
   973
@capability None
sl@0
   974
*/	
sl@0
   975
EXPORT_C TBool RSqlStatement::IsNull(TInt aColumnIndex) const
sl@0
   976
	{
sl@0
   977
	return Impl().ColumnType(aColumnIndex) == ESqlNull;
sl@0
   978
	}
sl@0
   979
sl@0
   980
/**
sl@0
   981
Gets the value of the column as a 32-bit integer.
sl@0
   982
sl@0
   983
The column is identified by the specified index value.
sl@0
   984
sl@0
   985
Note that the function can only be called after a successful call to Next(),
sl@0
   986
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
   987
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
   988
sl@0
   989
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
   990
sl@0
   991
@return The value of the column as a 32-bit integer.
sl@0
   992
sl@0
   993
@see KSqlAtRow
sl@0
   994
@see RSqlStatement::Prepare()
sl@0
   995
@see RSqlStatement::Next()                
sl@0
   996
sl@0
   997
@panic SqlDb 5 Column index out of bounds.
sl@0
   998
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
   999
sl@0
  1000
@capability None
sl@0
  1001
*/	
sl@0
  1002
EXPORT_C TInt RSqlStatement::ColumnInt(TInt aColumnIndex) const
sl@0
  1003
	{
sl@0
  1004
	return Impl().ColumnInt(aColumnIndex);
sl@0
  1005
	}
sl@0
  1006
	
sl@0
  1007
/**
sl@0
  1008
Gets the value of the column as a 64-bit integer.
sl@0
  1009
sl@0
  1010
The column is identified by the specified index value.
sl@0
  1011
sl@0
  1012
Note that the function can only be called after a successful call to Next(),
sl@0
  1013
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1014
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1015
sl@0
  1016
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1017
sl@0
  1018
@return The value of the column as a 64-bit integer.
sl@0
  1019
sl@0
  1020
@see KSqlAtRow
sl@0
  1021
@see RSqlStatement::Prepare()
sl@0
  1022
@see RSqlStatement::Next()                
sl@0
  1023
sl@0
  1024
@panic SqlDb 5 Column index out of bounds.
sl@0
  1025
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1026
sl@0
  1027
@capability None
sl@0
  1028
*/	
sl@0
  1029
EXPORT_C TInt64 RSqlStatement::ColumnInt64(TInt aColumnIndex) const
sl@0
  1030
	{
sl@0
  1031
	return Impl().ColumnInt64(aColumnIndex);
sl@0
  1032
	}
sl@0
  1033
	
sl@0
  1034
/**
sl@0
  1035
Gets the value of the column as a 64-bit floating point value.
sl@0
  1036
sl@0
  1037
The column is identified by the specified index value.
sl@0
  1038
sl@0
  1039
Note that the function can only be called after a successful call to Next(),
sl@0
  1040
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1041
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1042
sl@0
  1043
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1044
sl@0
  1045
@return The value of the column as a 64-bit floating point value.
sl@0
  1046
sl@0
  1047
@see KSqlAtRow
sl@0
  1048
@see RSqlStatement::Prepare()
sl@0
  1049
@see RSqlStatement::Next()                
sl@0
  1050
sl@0
  1051
@panic SqlDb 5 Column index out of bounds.
sl@0
  1052
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1053
sl@0
  1054
@capability None
sl@0
  1055
*/	
sl@0
  1056
EXPORT_C TReal RSqlStatement::ColumnReal(TInt aColumnIndex) const
sl@0
  1057
	{
sl@0
  1058
	return Impl().ColumnReal(aColumnIndex);
sl@0
  1059
	}
sl@0
  1060
sl@0
  1061
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1062
///////////////////////////          ColumnText ()           ///////////////////////////////////////////
sl@0
  1063
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1064
sl@0
  1065
/**
sl@0
  1066
Gets the value of the column as a 16-bit descriptor (leaves on failure).
sl@0
  1067
sl@0
  1068
The column is identified by the specified index value.
sl@0
  1069
sl@0
  1070
Note that the function can only be called after a successful call to Next(),
sl@0
  1071
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1072
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1073
sl@0
  1074
Note that when the text to be retrieved is over 2Mb in size then it is 
sl@0
  1075
recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. 
sl@0
  1076
These classes provide a more RAM-efficient way of retrieving large amounts 
sl@0
  1077
of text data from a database.
sl@0
  1078
sl@0
  1079
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1080
sl@0
  1081
@return A non-modifiable pointer descriptor representing the 16-bit column text.
sl@0
  1082
sl@0
  1083
@leave KErrNoMemory if the operation for retrieving the column value from the server
sl@0
  1084
                    fails with an out of memory condition.
sl@0
  1085
sl@0
  1086
@see KSqlAtRow
sl@0
  1087
@see RSqlStatement::ColumnText()
sl@0
  1088
@see RSqlStatement::Prepare()
sl@0
  1089
@see RSqlStatement::Next() 
sl@0
  1090
@see RSqlBlobReadStream
sl@0
  1091
@see TSqlBlob 
sl@0
  1092
sl@0
  1093
@panic SqlDb 5 Column index out of bounds.
sl@0
  1094
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1095
sl@0
  1096
@capability None
sl@0
  1097
*/
sl@0
  1098
EXPORT_C TPtrC RSqlStatement::ColumnTextL(TInt aColumnIndex) const
sl@0
  1099
	{
sl@0
  1100
	TPtrC res;
sl@0
  1101
	__SQLLEAVE_IF_ERROR(Impl().ColumnText(aColumnIndex, res));
sl@0
  1102
	return res;
sl@0
  1103
	}
sl@0
  1104
sl@0
  1105
/**
sl@0
  1106
Gets the value of the column as a 16-bit descriptor.
sl@0
  1107
sl@0
  1108
The column is identified by the specified index value.
sl@0
  1109
sl@0
  1110
Note that the function can only be called after a successful call to Next(),
sl@0
  1111
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1112
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1113
sl@0
  1114
Note that when the text to be retrieved is over 2Mb in size then it is 
sl@0
  1115
recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. 
sl@0
  1116
These classes provide a more RAM-efficient way of retrieving large amounts 
sl@0
  1117
of text data from a database.
sl@0
  1118
sl@0
  1119
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1120
@param aPtr         A non-modifiable pointer descriptor. On successful completion of this
sl@0
  1121
                    function, the pointer descriptor represents the 16-bit column text.
sl@0
  1122
                    The descriptor does not change if the function fails.
sl@0
  1123
sl@0
  1124
@return KErrNone, if the function completes successfully,
sl@0
  1125
                  otherwise one of the other system-wide error codes.
sl@0
  1126
sl@0
  1127
@see KSqlAtRow
sl@0
  1128
@see RSqlStatement::ColumnTextL()
sl@0
  1129
@see RSqlStatement::Prepare()
sl@0
  1130
@see RSqlStatement::Next()   
sl@0
  1131
@see RSqlBlobReadStream
sl@0
  1132
@see TSqlBlob
sl@0
  1133
sl@0
  1134
@panic SqlDb 5 Column index out of bounds.
sl@0
  1135
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1136
sl@0
  1137
@capability None
sl@0
  1138
*/	
sl@0
  1139
EXPORT_C TInt RSqlStatement::ColumnText(TInt aColumnIndex, TPtrC& aPtr) const
sl@0
  1140
	{
sl@0
  1141
	return Impl().ColumnText(aColumnIndex, aPtr);
sl@0
  1142
	}
sl@0
  1143
	
sl@0
  1144
/**
sl@0
  1145
Interprets the value of the column as a 16-bit descriptor, and copies the data
sl@0
  1146
into a 16-bit modifiable descriptor supplied by the caller.
sl@0
  1147
sl@0
  1148
The column is identified by the specified index value.
sl@0
  1149
sl@0
  1150
Note that the function can only be called after a successful call to Next(),
sl@0
  1151
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1152
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1153
sl@0
  1154
Note that when the text to be retrieved is over 2Mb in size then it is 
sl@0
  1155
recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. 
sl@0
  1156
These classes provide a more RAM-efficient way of retrieving large amounts 
sl@0
  1157
of text data from a database.
sl@0
  1158
sl@0
  1159
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1160
@param aDest        A 16-bit modifiable descriptor into which the column data is to be copied.
sl@0
  1161
sl@0
  1162
@return KErrNone,     the operation has completed successfully;
sl@0
  1163
        KErrOverflow, the maximum length of the target descriptor supplied by
sl@0
  1164
                      the caller (aDest) is less than the length of
sl@0
  1165
                      the column text - the column data
sl@0
  1166
                      is truncated to fit into the target descriptor.
sl@0
  1167
        KErrNoMemory, an out of memory condition has occurred.
sl@0
  1168
sl@0
  1169
@see KSqlAtRow
sl@0
  1170
@see RSqlStatement::Prepare()
sl@0
  1171
@see RSqlStatement::Next()   
sl@0
  1172
@see RSqlBlobReadStream
sl@0
  1173
@see TSqlBlob
sl@0
  1174
sl@0
  1175
@panic SqlDb 5 Column index out of bounds.
sl@0
  1176
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1177
sl@0
  1178
@capability None
sl@0
  1179
*/	
sl@0
  1180
EXPORT_C TInt RSqlStatement::ColumnText(TInt aColumnIndex, TDes& aDest) const
sl@0
  1181
	{
sl@0
  1182
	return Impl().ColumnText(aColumnIndex, aDest);
sl@0
  1183
	}
sl@0
  1184
sl@0
  1185
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1186
///////////////////////////          ColumnBinary ()           /////////////////////////////////////////
sl@0
  1187
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1188
	
sl@0
  1189
/**
sl@0
  1190
Gets the value of the column as an 8-bit descriptor (leaves on failure).
sl@0
  1191
sl@0
  1192
The column is identified by the specified index value.
sl@0
  1193
sl@0
  1194
Note that the function can only be called after a successful call to Next(),
sl@0
  1195
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1196
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1197
sl@0
  1198
Note that when the binary data to be retrieved is over 2Mb in size then it 
sl@0
  1199
is recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. 
sl@0
  1200
These classes provide a more RAM-efficient way of retrieving large amounts 
sl@0
  1201
of binary data from a database.
sl@0
  1202
sl@0
  1203
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1204
sl@0
  1205
@return A non-modifiable pointer descriptor representing the 8-bit column data.
sl@0
  1206
sl@0
  1207
@leave KErrNoMemory if the operation for retrieving the column value from the server
sl@0
  1208
                    fails with an out of memory condition.
sl@0
  1209
sl@0
  1210
@see KSqlAtRow
sl@0
  1211
@see RSqlStatement::ColumnBinary()
sl@0
  1212
@see RSqlStatement::Prepare()
sl@0
  1213
@see RSqlStatement::Next()   
sl@0
  1214
@see RSqlBlobReadStream
sl@0
  1215
@see TSqlBlob
sl@0
  1216
sl@0
  1217
@panic SqlDb 5 Column index out of bounds.
sl@0
  1218
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1219
sl@0
  1220
@capability None
sl@0
  1221
*/
sl@0
  1222
EXPORT_C TPtrC8 RSqlStatement::ColumnBinaryL(TInt aColumnIndex) const
sl@0
  1223
	{
sl@0
  1224
	TPtrC8 res;
sl@0
  1225
	__SQLLEAVE_IF_ERROR(Impl().ColumnBinary(aColumnIndex, res));
sl@0
  1226
	return res;
sl@0
  1227
	}
sl@0
  1228
sl@0
  1229
/**
sl@0
  1230
Gets the value of the column as an 8-bit descriptor.
sl@0
  1231
sl@0
  1232
The column is identified by the specified index value.
sl@0
  1233
sl@0
  1234
Note that the function can only be called after a successful call to Next(),
sl@0
  1235
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1236
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1237
sl@0
  1238
Note that when the binary data to be retrieved is over 2Mb in size then it 
sl@0
  1239
is recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. 
sl@0
  1240
These classes provide a more RAM-efficient way of retrieving large amounts 
sl@0
  1241
of binary data from a database.
sl@0
  1242
sl@0
  1243
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1244
@param aPtr         A non-modifiable pointer descriptor. On successful completion of this
sl@0
  1245
                    function, the pointer descriptor represents the 8-bit column data.
sl@0
  1246
                    The descriptor does not change if the function fails.
sl@0
  1247
sl@0
  1248
@return KErrNone, if the function completes successfully,
sl@0
  1249
                  otherwise one of the other system-wide error codes.
sl@0
  1250
sl@0
  1251
@see KSqlAtRow
sl@0
  1252
@see RSqlStatement::ColumnBinaryL()
sl@0
  1253
@see RSqlStatement::Prepare()
sl@0
  1254
@see RSqlStatement::Next()   
sl@0
  1255
@see RSqlBlobReadStream
sl@0
  1256
@see TSqlBlob
sl@0
  1257
sl@0
  1258
@panic SqlDb 5 Column index out of bounds.
sl@0
  1259
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1260
sl@0
  1261
@capability None
sl@0
  1262
*/	
sl@0
  1263
EXPORT_C TInt RSqlStatement::ColumnBinary(TInt aColumnIndex, TPtrC8& aPtr) const
sl@0
  1264
	{
sl@0
  1265
   	return Impl().ColumnBinary(aColumnIndex, aPtr);
sl@0
  1266
	}
sl@0
  1267
	
sl@0
  1268
/**
sl@0
  1269
Interprets the value of the column as an 8-bit descriptor, and copies the data
sl@0
  1270
into an 8-bit modifiable descriptor supplied by the caller.
sl@0
  1271
sl@0
  1272
The column is identified by the specified index value.
sl@0
  1273
sl@0
  1274
Note that the function can only be called after a successful call to Next(),
sl@0
  1275
i.e. after a call to Next() that has completed with a KSqlAtRow return code.
sl@0
  1276
Calling this function after an unsuccessful call to Next() raises a panic.
sl@0
  1277
sl@0
  1278
Note that when the binary data to be retrieved is over 2Mb in size then it 
sl@0
  1279
is recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. 
sl@0
  1280
These classes provide a more RAM-efficient way of retrieving large amounts 
sl@0
  1281
of binary data from a database.
sl@0
  1282
sl@0
  1283
@param aColumnIndex The index value identifying the column; this is 0 for the first column.
sl@0
  1284
@param aDest        An 8-bit modifiable descriptor into which the column data is to be copied.
sl@0
  1285
sl@0
  1286
@return KErrNone,     the operation has completed successfully;
sl@0
  1287
        KErrOverflow, the maximum length of the target descriptor supplied by
sl@0
  1288
                      the caller (aDest) is less than the length of
sl@0
  1289
                      the column data - the column data
sl@0
  1290
                      is truncated to fit into the target descriptor.
sl@0
  1291
        KErrNoMemory, an out of memory condition has occurred.
sl@0
  1292
sl@0
  1293
@see KSqlAtRow
sl@0
  1294
@see RSqlStatement::Prepare()
sl@0
  1295
@see RSqlStatement::Next()   
sl@0
  1296
@see RSqlBlobReadStream
sl@0
  1297
@see TSqlBlob
sl@0
  1298
sl@0
  1299
@panic SqlDb 5 Column index out of bounds.
sl@0
  1300
@panic SqlDb 11 Statement cursor not positioned on a row
sl@0
  1301
sl@0
  1302
@capability None
sl@0
  1303
*/	
sl@0
  1304
EXPORT_C TInt RSqlStatement::ColumnBinary(TInt aColumnIndex, TDes8& aDest) const
sl@0
  1305
	{
sl@0
  1306
   	return Impl().ColumnBinary(aColumnIndex, aDest);
sl@0
  1307
	}
sl@0
  1308
sl@0
  1309
/**
sl@0
  1310
Obtain the name of a column after preparing a query.
sl@0
  1311
sl@0
  1312
@param aColumnIndex Column index
sl@0
  1313
@param aNameDest Descriptor which will be set to column name
sl@0
  1314
@return KErrNone if successfull or one of the system-wide error codes on error
sl@0
  1315
@capability None
sl@0
  1316
*/
sl@0
  1317
EXPORT_C TInt RSqlStatement::ColumnName(TInt aColumnIndex, TPtrC& aNameDest)
sl@0
  1318
	{
sl@0
  1319
	return Impl().ColumnName(aColumnIndex, aNameDest);
sl@0
  1320
	}
sl@0
  1321
sl@0
  1322
/**
sl@0
  1323
Obtain the name of a parameter after preparing a DML query.
sl@0
  1324
The parameter names are returned in exactly the same form as
sl@0
  1325
supplied in SQL statement. For example, if the parameter name is ":Prm", 
sl@0
  1326
then the ":" prefix will not be omitted.
sl@0
  1327
sl@0
  1328
This function can be called at any time after the DML SQL statement has been prepared.
sl@0
  1329
sl@0
  1330
@param aParameterIndex Parameter index
sl@0
  1331
@param aNameDest Descriptor which will be set to column name
sl@0
  1332
@return KErrNone if successfull or one of the system-wide error codes on error
sl@0
  1333
@capability None
sl@0
  1334
*/
sl@0
  1335
EXPORT_C TInt RSqlStatement::ParameterName(TInt aParameterIndex, TPtrC& aNameDest)
sl@0
  1336
	{
sl@0
  1337
	return Impl().ParameterName(aParameterIndex, aNameDest);
sl@0
  1338
	}
sl@0
  1339
sl@0
  1340
/**
sl@0
  1341
Obtain the name of a parameter after preparing a DML query.
sl@0
  1342
The parameter names are returned in exactly the same form as
sl@0
  1343
supplied in SQL statement. For example, if the parameter name is ":Prm", 
sl@0
  1344
then the ":" prefix will not be omitted.
sl@0
  1345
sl@0
  1346
ParamName has the same behaviour as ParameterName. It is provided to maintain
sl@0
  1347
source compatibility with previous Symbian releases.
sl@0
  1348
sl@0
  1349
This function can be called at any time after the DML SQL statement has 
sl@0
  1350
been prepared.
sl@0
  1351
sl@0
  1352
@param aParameterIndex Parameter index
sl@0
  1353
@param aNameDest Descriptor which will be set to parameter name
sl@0
  1354
@return KErrNone if successful or one of the system-wide error codes on error
sl@0
  1355
@capability None
sl@0
  1356
*/
sl@0
  1357
EXPORT_C TInt RSqlStatement::ParamName(TInt aParameterIndex, TPtrC& aNameDest)
sl@0
  1358
	{
sl@0
  1359
	return ParameterName(aParameterIndex, aNameDest);
sl@0
  1360
	}
sl@0
  1361
sl@0
  1362
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1363
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1364
////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1365
	
sl@0
  1366
/**
sl@0
  1367
Returns a reference to the implementation object of RSqlStatement - CSqlStatementImpl.
sl@0
  1368
sl@0
  1369
@panic SqlDb 2  The SQL statement has not been prepared,
sl@0
  1370
                i.e. Prepare() has not yet been called on this RSqlStatement object.
sl@0
  1371
sl@0
  1372
@internalComponent
sl@0
  1373
*/
sl@0
  1374
CSqlStatementImpl& RSqlStatement::Impl() const
sl@0
  1375
	{
sl@0
  1376
	__ASSERT_ALWAYS(iImpl != NULL, __SQLPANIC(ESqlPanicInvalidObj));
sl@0
  1377
	return *iImpl;	
sl@0
  1378
	}