Re: [sqlite] select prepared statement always returning SQLITE_DONE

2013-08-03 Thread ibrahim
after sqlite3_reset () all bound parameters keep their values they are 
not unbound or nullified by default so for that purpose you would have 
to call sqlite3_call_bindings ()


see link http://www.sqlite.org/c3ref/clear_bindings.html

this is not necessary if you want to keep all bound values except of 
those you reset with new values.


On 02.08.2013 06:22, ngsbioinformat...@gmail.com wrote:

Hi all - I've got sqlite embedded in an iOS app.  I have a database with 1
table, and am creating a prepared select statement with a where clause on 1
field.  In my loop, my order of operations is: sqlite3_bind_text,
sqlite3_step, sqlite3_reset.

One the first iteration of the loop, sqlite3_step returns SQLITE_ROW and
all the correct values.  On the second and every subsequent iteration,
sqlite3_step returns SQLITE_DONE.  Why is this?  I thought I could call
sqlite3_reset then rebind a variable and called step again. All the
documentation points to this being correct.  Am I missing something?

Ryan



___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] select prepared statement always returning SQLITE_DONE

2013-08-02 Thread Kees Nuyt
On Thu, 1 Aug 2013 21:22:23 -0700 (PDT), ngsbioinformat...@gmail.com
wrote:

>Hi all - I've got sqlite embedded in an iOS app.  I have a database with 1 
>table, and am creating a prepared select statement with a where clause on 1 
>field.  In my loop, my order of operations is: sqlite3_bind_text, 
>sqlite3_step, sqlite3_reset.
>
>One the first iteration of the loop, sqlite3_step returns SQLITE_ROW and 
>all the correct values.  On the second and every subsequent iteration, 
>sqlite3_step returns SQLITE_DONE.  Why is this?  I thought I could call 
>sqlite3_reset then rebind a variable and called step again. All the 
>documentation points to this being correct.  Am I missing something?  
>
>Ryan


You appear to do

_prepare()
loop
_bind()
_step()
[ if not _DONE use results ]
_reset()
end loop

_reset() resets the statement, so the cursor is invalidated and the
statement is re-initialized. This way you will always only retrieve

* either zero rows (the WHERE clause doesn't match anything)
.. in this case _step() returns no data and status SQLITE_DONE
* or one row (the WHERE clause matches one or more rows)

Perhaps this is not what you meant to do?

Typically, re-using a prepared statement has this structure:
_prepare()
loop 1 until bind list exhausted
_bind()
loop 2 until SQLITE_DONE
_step()
[ if not _DONE use results ]
end loop 2 
_reset()
end loop 1
_finalize()

But perhaps I don't understand your problem?

-- 
Groet, Cordialement, Pozdrawiam, Regards,

Kees Nuyt

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] select prepared statement always returning SQLITE_DONE

2013-08-02 Thread Richard Hipp
On Fri, Aug 2, 2013 at 12:22 AM,  wrote:

> Hi all - I've got sqlite embedded in an iOS app.  I have a database with 1
> table, and am creating a prepared select statement with a where clause on 1
> field.  In my loop, my order of operations is: sqlite3_bind_text,
> sqlite3_step, sqlite3_reset.
>
> One the first iteration of the loop, sqlite3_step returns SQLITE_ROW and
> all the correct values.  On the second and every subsequent iteration,
> sqlite3_step returns SQLITE_DONE.  Why is this?


That means that the second and subsequent iterations found no rows.



>  I thought I could call
> sqlite3_reset then rebind a variable and called step again. All the
> documentation points to this being correct.
>

That is correct.  Maybe your rebound values are such that the query is
returning no rows?


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] select prepared statement always returning SQLITE_DONE

2013-08-02 Thread ngsbioinformatics
Hi all - I've got sqlite embedded in an iOS app.  I have a database with 1 
table, and am creating a prepared select statement with a where clause on 1 
field.  In my loop, my order of operations is: sqlite3_bind_text, 
sqlite3_step, sqlite3_reset.

One the first iteration of the loop, sqlite3_step returns SQLITE_ROW and 
all the correct values.  On the second and every subsequent iteration, 
sqlite3_step returns SQLITE_DONE.  Why is this?  I thought I could call 
sqlite3_reset then rebind a variable and called step again. All the 
documentation points to this being correct.  Am I missing something?  

Ryan

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users