[sqlite] sqldiff -- interpreting the data

2016-09-17 Thread Kumar Suraj
Can anyone please tell me when i use SQLdiff --summary option what does the
following row means

tablename:0 changes,0 inserts , 288 deletes, 0 unchanged..
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[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,
>  , 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-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,
 , 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] error during bind

2015-07-06 Thread Kumar Suraj
Thanks a lot .. this helped..

On Fri, Jul 3, 2015 at 10:16 PM, Simon Slavin  wrote:

>
> On 3 Jul 2015, at 5:16pm, Kumar Suraj  wrote:
>
> > So whats the solution here. I am giving 4 statements because i need
> insert
> > to be transactional. Some other process could be inserting in the same db
> > and so we need insert and row id values to be in one transaction.  Is
> there
> > any other way i can achieve it.
>
> Just issue your SQL commands as four separate commands.  The database
> knows that they all came from the same connection and it will keep the
> database locked for you until you COMMIT.
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] error during bind

2015-07-03 Thread Kumar Suraj
Hi

So whats the solution here. I am giving 4 statements because i need insert
to be transactional. Some other process could be inserting in the same db
and so we need insert and row id values to be in one transaction.  Is there
any other way i can achieve it.

-Suraj

On Fri, Jul 3, 2015 at 5:13 PM, Stephan Beal  wrote:

> On Fri, Jul 3, 2015 at 1:39 PM, Kumar Suraj  wrote:
>
> > #define INSERT_DN "BEGIN TRANSACTION; INSERT INTO TBL (dn) VALUES (?);
> > SELECT last_insert_rowid(); COMMIT;"
> >
> >
> prepare() expects a _single_ statement. You're giving it 4 statements and
> then trying to bind to part of that, which won't work.
>
>
> > snprintf(command, 512, INSERT_DN);
> >
>
> --
> - stephan beal
> http://wanderinghorse.net/home/stephan/
> http://gplus.to/sgbeal
> "Freedom is sloppy. But since tyranny's the only guaranteed byproduct of
> those who insist on a perfect world, freedom will have to do." -- Bigby
> Wolf
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] error during bind

2015-07-03 Thread Kumar Suraj
Hi

I have trying to insert in a sqlite db.. here is the code but i am getting
following error.. what could be the issue.

*Error Insert : sqlite3_bind_blob, Error code : 25*

#define INSERT_DN "BEGIN TRANSACTION; INSERT INTO TBL (dn) VALUES (?);
SELECT last_insert_rowid(); COMMIT;"

BinBuffer aInBuffer
char buffer[100] = "a/b/c/d";
char * testdn = buffer;
aInBuffer.size = 100;
aInBuffer.ptr = testdn;

reset_stmt(newStmt);
snprintf(command, 512, INSERT_DN);
if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, -1,
 , NULL) ) != SQLITE_OK )
{
   fprintf(stderr, "Error Insert : sqlite3_prepare_v2, Error code :
%d\n", rv);
   return;
}
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);
return;
}


[sqlite] error during sqlite_bind

2015-04-09 Thread Kumar Suraj
I tried suggested and see the correct query.. so i am not sure whats going
wrong.. any insight..

query is select kindex from TBL where dn=?
select kindex from TBL where dn=?
debug information string a/b/c/d size 8
Error Insert : sqlite3_bind_blob, Error code : 25


snprintf(command, 512, SELECT_DN);
// todo remove this printf call
fprintf(stderr, "query is %s\n", command);
if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command,
strlen(command),
 , NULL) ) != SQLITE_OK )
{
   fprintf(stderr, "Error Insert : sqlite3_prepare_v2, Error code :
%d\n", rv);
   return;
}
// todo remove the 2 lines
const char *savedcopy = sqlite3_sql(newStmt);
fprintf(stderr, "%s\n", savedcopy);
fprintf(stderr, "debug information string %s size %lu\n",
aInBuffer.ptr, sizeof(aInBuffer.ptr));
rv = sqlite3_bind_blob(newStmt, 1, aInBuffer.ptr,
sizeof(aInBuffer.ptr), SQLITE_STATIC);


On Tue, Apr 7, 2015 at 6:40 PM, Richard Hipp  wrote:

> On 4/7/15, Igor Tandetnik  wrote:
> > On 4/7/2015 9:11 PM, Kumar Suraj wrote:
> >> You can add this to top of the code..
> >>
> >> char command[512];
> >>  snprintf(command, 512, SELECT_DN);
> >
> > I don't see anything wrong in the code you've shown. The problem must
> > lie in the code you haven't. My guess would be, the query you are
> > preparing is not the query you think you are preparing. Print "command"
> > and strlen(command) right before sqlite3_prepare_v2 call, to
> double-check.
>
> Or, print the result of sqlite3_sql(newStmt) right after
> sqlite3_prepare_v2() returns successfully.
> --
> D. Richard Hipp
> drh at sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] error during sqlite_bind

2015-04-07 Thread Kumar Suraj
You can add this to top of the code..

char command[512];
snprintf(command, 512, SELECT_DN);

On Tue, Apr 7, 2015 at 6:11 PM, Kumar Suraj  wrote:

> I have not added the whole code.. command is defined.. in my code..
>
> On Tue, Apr 7, 2015 at 5:42 PM, Igor Tandetnik  wrote:
>
>> On 4/7/2015 8:04 PM, Kumar Suraj wrote:
>>
>>> if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, strlen(command),
>>>   , NULL) ) != SQLITE_OK )
>>>
>>
>> command: undeclared identifier.
>>
>> --
>> Igor Tandetnik
>>
>> ___
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>


[sqlite] error during sqlite_bind

2015-04-07 Thread Kumar Suraj
I have not added the whole code.. command is defined.. in my code..

On Tue, Apr 7, 2015 at 5:42 PM, Igor Tandetnik  wrote:

> On 4/7/2015 8:04 PM, Kumar Suraj wrote:
>
>> if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, strlen(command),
>>   , NULL) ) != SQLITE_OK )
>>
>
> command: undeclared identifier.
>
> --
> Igor Tandetnik
>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] error during sqlite_bind

2015-04-07 Thread Kumar Suraj
Hi

I am trying to use SQLite c api to create a db, table and then do a select
query but i am getting following error

#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */

Here is the code call

#define SELECT_DN "select kindex from TBL where dn=?"

 char buffer[100] = "a/b/c/d";
char * testdn = buffer;
lBuffer.size = 100;
lBuffer.ptr = testdn;

if ( (rv = sqlite3_prepare_v2(sqlHandle->db, command, strlen(command),
 , NULL) ) != SQLITE_OK )
{
   fprintf(stderr, "Error Insert : sqlite3_prepare_v2, Error code :
%d\n", rv);
   return;
}
rv = sqlite3_bind_blob(newStmt, 1, lBuffer.ptr, lBuffer.size,
SQLITE_STATIC);
if (rv != SQLITE_OK)
{
fprintf(stderr, "Error Insert : sqlite3_bind_blob, Error code :
%d\n", rv);
return;
}


[sqlite] insert in sqlite (returning value for inserted row)

2015-04-01 Thread Kumar Suraj
Hi Richard.. this wont work for me due to following reason.

If a separate thread performs a new INSERT
<https://www.sqlite.org/lang_insert.html> on the same database connection
while the sqlite3_last_insert_rowid()
<https://www.sqlite.org/c3ref/last_insert_rowid.html> function is running
and thus changes the last insert rowid
<https://www.sqlite.org/lang_createtable.html#rowid>, then the value
returned by sqlite3_last_insert_rowid()
<https://www.sqlite.org/c3ref/last_insert_rowid.html> is unpredictable and
might not equal either the old or the new last insert rowid
<https://www.sqlite.org/lang_createtable.html#rowid>.

On Tue, Mar 31, 2015 at 6:23 PM, Richard Hipp  wrote:

> https://www.sqlite.org/c3ref/last_insert_rowid.html
>
> On Tue, Mar 31, 2015 at 9:19 PM, Kumar Suraj  wrote:
>
> > Hi
> >
> > I am using sqlite C interface for inserting data in the table. The
> primary
> > key is a 64 bit integer which i need to auto-increment and get populated
> > automatically as we do not provide that value in insert statement. Is
> there
> > a way i can get the autoincremented value for each row inserted when
> ever i
> > execute my insert.
> >
> > -Suraj
> > ___
> > sqlite-users mailing list
> > sqlite-users at mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
>
>
>
> --
> D. Richard Hipp
> drh at sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


[sqlite] SQLITE_IOERR_SHORT_READ error

2015-03-20 Thread Kumar Suraj
 Hi

We are using SQLite in our infrastructure and calling following API

sqlite3_step (
but we get error SQLITE_IOERR_SHORT_READ once in a while. While

error is Ok for us we were interested to know whether there are retries made

internally when ever SQLite encounter this kind of error.

Thanks