[sqlite] sqlite error 25 during bind

2016-04-10 Thread Kumar Suraj
Any idea what could be wrong here..

On Sat, Apr 9, 2016 at 5:10 PM, Kumar Suraj  wrote:

> Yes i am calling sqlite3_prepare_v2
>
>  snprintf(command, 512, INSERT_DN);
> if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, -1,
>  &newStmt, NULL) ) != SQLITE_OK )
> {
>fprintf(stderr, "Error Insert : sqlite3_prepare_v2, Error code
> : %d\n", rv);
>sqlite3_finalize(newStmt);
>return rv;
> }
> rv = sqlite3_bind_blob(newStmt, 1, aInBuffer.ptr, aInBuffer.size,
> SQLITE_STATIC);
> if (rv != SQLITE_OK)
> {
> fprintf(stderr, "Error Insert : sqlite3_bind_blob, Error code
> : %d\n", rv);
> sqlite3_finalize(newStmt);
> return rv;
> }
> rv = sqlite3_bind_int(newStmt, 2 , aInClassId);
> if (rv != SQLITE_OK)
> {
> fprintf(stderr, "Error Insert : sqlite3_bind_int, Error code :
> %d\n", rv);
> sqlite3_finalize(newStmt);
> return rv;
> }
>
>
> On Wed, Apr 6, 2016 at 4:55 PM, Simon Davies  > wrote:
>
>> On 6 April 2016 at 12:16, Kumar Suraj  wrote:
>> > Hi
>> .
>> .
>> .
>> > Here is table definition and insert statement which is causing this
>> >
>> > #define CREATE_TABLE_DNINDEX "CREATE TABLE IF NOT EXISTS TBL (dn BLOB,
>> > pclassid INTEGER, pkey INTEGER, kindex INTEGER PRIMARY KEY ASC)"
>> >
>> > #define INSERT_DN "INSERT INTO TBL (dn,pclassid,pkey) VALUES (?,?,?);"
>> >
>> >  rv = sqlite3_bind_int(newStmt, 2 , aInClassId);
>> >
>> > if (rv != SQLITE_OK)
>> >
>> > {
>> >
>> > fprintf(stderr, "Error Insert : sqlite3_bind_int, Error
>> code :
>> > %d\n", rv);
>> >
>> > sqlite3_finalize(newStmt);
>> >
>> > return rv;
>> >
>> > }
>>
>> Are you calling sqlite3_prepare_v2 before your call to sqlite3_bind_int?
>>
>> Regards,
>> Simon
>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>


[sqlite] sqlite error 25 during bind

2016-04-10 Thread Olivier Mascia
Le 10 avr. 2016 ? 14:12, Kumar Suraj  a ?crit :
> 
> Any idea what could be wrong here..

Have you checked the return value of sqlite3_bind_parameter_count(newStmt) 
after successful call to sqlite3_prepare_v2()?

I would also output the string returned by sqlite3_sql(newStmt) in your error 
paths, just to be clear the prepared statement is really the one you expect.

-- 
Meilleures salutations, Met vriendelijke groeten, Best Regards,
Olivier Mascia, integral.be/om





[sqlite] sqlite error 25 during bind

2016-04-10 Thread Simon Slavin

On 10 Apr 2016, at 1:12pm, Kumar Suraj  wrote:

> Any idea what could be wrong here..

The error indicates you're trying to bind to, for example, item 4 when the 
string only has two binding points.

Use a debugger to show the string you're binding to at the last possible point.

Simon.


[sqlite] sqlite error 25 during bind

2016-04-09 Thread Kumar Suraj
Yes i am calling sqlite3_prepare_v2

 snprintf(command, 512, INSERT_DN);
if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, -1,
 &newStmt, NULL) ) != SQLITE_OK )
{
   fprintf(stderr, "Error Insert : sqlite3_prepare_v2, Error code :
%d\n", rv);
   sqlite3_finalize(newStmt);
   return rv;
}
rv = sqlite3_bind_blob(newStmt, 1, aInBuffer.ptr, aInBuffer.size,
SQLITE_STATIC);
if (rv != SQLITE_OK)
{
fprintf(stderr, "Error Insert : sqlite3_bind_blob, Error code :
%d\n", rv);
sqlite3_finalize(newStmt);
return rv;
}
rv = sqlite3_bind_int(newStmt, 2 , aInClassId);
if (rv != SQLITE_OK)
{
fprintf(stderr, "Error Insert : sqlite3_bind_int, Error code :
%d\n", rv);
sqlite3_finalize(newStmt);
return rv;
}


On Wed, Apr 6, 2016 at 4:55 PM, Simon Davies 
wrote:

> On 6 April 2016 at 12:16, Kumar Suraj  wrote:
> > Hi
> .
> .
> .
> > Here is table definition and insert statement which is causing this
> >
> > #define CREATE_TABLE_DNINDEX "CREATE TABLE IF NOT EXISTS TBL (dn BLOB,
> > pclassid INTEGER, pkey INTEGER, kindex INTEGER PRIMARY KEY ASC)"
> >
> > #define INSERT_DN "INSERT INTO TBL (dn,pclassid,pkey) VALUES (?,?,?);"
> >
> >  rv = sqlite3_bind_int(newStmt, 2 , aInClassId);
> >
> > if (rv != SQLITE_OK)
> >
> > {
> >
> > fprintf(stderr, "Error Insert : sqlite3_bind_int, Error code
> :
> > %d\n", rv);
> >
> > sqlite3_finalize(newStmt);
> >
> > return rv;
> >
> > }
>
> Are you calling sqlite3_prepare_v2 before your call to sqlite3_bind_int?
>
> Regards,
> Simon
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] sqlite error 25 during bind

2016-04-06 Thread Kumar Suraj
Hi

I am getting following error in this piece of code.. Any idea what could be
wrong ?

*(25) SQLITE_RANGE*

The SQLITE_RANGE error indices that the parameter number argument to one of
the sqlite3_bind  routines or
the column number in one of the sqlite3_column
routines is out of range.

Here is table definition and insert statement which is causing this

#define CREATE_TABLE_DNINDEX "CREATE TABLE IF NOT EXISTS TBL (dn BLOB,
pclassid INTEGER, pkey INTEGER, kindex INTEGER PRIMARY KEY ASC)"

#define INSERT_DN "INSERT INTO TBL (dn,pclassid,pkey) VALUES (?,?,?);"

 rv = sqlite3_bind_int(newStmt, 2 , aInClassId);

if (rv != SQLITE_OK)

{

fprintf(stderr, "Error Insert : sqlite3_bind_int, Error code :
%d\n", rv);

sqlite3_finalize(newStmt);

return rv;

}


[sqlite] sqlite error 25 during bind

2016-04-06 Thread Simon Davies
On 6 April 2016 at 12:16, Kumar Suraj  wrote:
> Hi
. 
. 
. 
> Here is table definition and insert statement which is causing this
>
> #define CREATE_TABLE_DNINDEX "CREATE TABLE IF NOT EXISTS TBL (dn BLOB,
> pclassid INTEGER, pkey INTEGER, kindex INTEGER PRIMARY KEY ASC)"
>
> #define INSERT_DN "INSERT INTO TBL (dn,pclassid,pkey) VALUES (?,?,?);"
>
>  rv = sqlite3_bind_int(newStmt, 2 , aInClassId);
>
> if (rv != SQLITE_OK)
>
> {
>
> fprintf(stderr, "Error Insert : sqlite3_bind_int, Error code :
> %d\n", rv);
>
> sqlite3_finalize(newStmt);
>
> return rv;
>
> }

Are you calling sqlite3_prepare_v2 before your call to sqlite3_bind_int?

Regards,
Simon