[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sqlite-users
Subject:    Re: [sqlite] Nested calls to prepare/step/prepare
From:       "Jay A. Kreibich" <jay () kreibi ! ch>
Date:       2008-02-29 14:46:58
Message-ID: 20080229144658.GA5423 () uiuc ! edu
[Download RAW message or body]

On Fri, Feb 29, 2008 at 11:50:32AM +0700, Dan scratched on the wall:
> 
> On Feb 29, 2008, at 5:21 AM, Ken wrote:
> 
> > I wanted to find out if the following is allowed in Sqlite.
> >
> >    sqlite3_prepare_v2
> > while ( ) {
> >    sqlite3_step
> >      sqlite3_prepare_v2   --- I;m getting a segv here.
> >      while ( ) {
> >                sqlite3_step
> >     }
> > }
> >
> >
> > So my questing is, does sqlite allow a prepare to be started while  
> > a prior prepared statement is still open?
> 
> This is supposed to be Ok. If you can supply an example program
> to demonstrate the crash that would be very helpful.

  I've pre-prepared the statements and then just executed them in a
  nested fashon.  That only works if you know exactly what statements
  you need, but I've found this is often the case.

  e.g.:

  sqlite3_prepare_v2( ...stmt1... );
  sqlite3_prepare_v2( ...stmt2... );

  sqlite3_bind...( ...stmt1... );
  while( sqlite3_step( ...stmt1...) ) {
  	// extract data from step above
  	sqlite3_bind...( ...stmt2... );
	sqlite3_step( ...stmt2... );  // or loop, if required
	sqlite3_reset( ...stmt2... );
	sqlite3_clear_bindings( ...stmt2... );
  }
  



  This brings up a somewhat related question I was wondering about.  Is
  there any documentation on how many "in-flight" statements a single
  database handle can have open?  For example, how many prepared
  statements I can have somewhere between their first sqlite3_step()
  call and sqlite3_reset().  Also, are there any limits on how those
  statements interact?  Will the inner statement be run in its own
  transaction?  Does the outer statement need to be a read-only
  statement?

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"'People who live in bamboo houses should not throw pandas.' Jesus said that."
   - "The Ninja", www.AskANinja.com, "Special Delivery 10: Pop!Tech 2006"
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic