Re: [sqlite] Row count after prepare

2005-03-16 Thread Marcelo Zamateo
Leif:
There may be better solutions, but you don't need to scan the SQL, just  
put it as subquery:
sqlite3_printf "Select Count(*) from (%s)", pSQL
will do the work for you.
Remember what i said about Group by clauses.
Anyway i think a function like sqlite3_row_count(hStmt) would be fantastic.
Marcelo.





Re: [sqlite] Row count after prepare

2005-03-15 Thread Leif Jensen
  Hi Marcelo,
  It would, but I don't know the contents of the SQL at the point where 
I need get the row count, so I would have to scan the statement. Putting 
in the extra 'count(*)' all over is not really possible.

  Does anyone know the timing of  a sqlite3_step() compared to 
sqlite3_step() + sqlite_column_() ?

Leif
Marcelo Zamateo wrote:
Hi Leif:
Will "Select Count(*) from (Your_SQL)" give you what you want?
Be careful if Your_SQL includes Group By clause, don't know if work 
as  expected.
Marcelo





Re: [sqlite] Row count after prepare

2005-03-15 Thread Marcelo Zamateo
Hi Leif:
Will "Select Count(*) from (Your_SQL)" give you what you want?
Be careful if Your_SQL includes Group By clause, don't know if work as  
expected.
Marcelo





Re: [sqlite] Row count after prepare

2005-03-15 Thread Kurt Welgehausen
> ... guess I will have to use sqlite3_get_table in this case

Be aware that sqlite3_get_table is no longer a recommended
API and may not do everything you want. See



Regards


Re: [sqlite] Row count after prepare

2005-03-15 Thread Leif Jensen
  Hi Dan,
 Ah yes, of course  (I knew this was a newbie question ;-) ). So I 
guess I will have to use sqlite3_get_table in this case.

 Thank you for the enlightment,
Leif
Dan Kennedy wrote:
--- Leif Jensen <[EMAIL PROTECTED]> wrote:
 

   Hi All,
   I'm quite new to SQLite, but like it very much.
  I am trying it out for an existing applicationm which seems good, but 
I have one problem:

  How do I get the number of rows in the result set after having called 
sqlite3_prepare( ... ) ? Of course I could call sqlite3_step() until no 
more rows are returned, but isn't there a better way ?
   

It can't be done. Calling sqlite3_prepare() just compiles the SQL to 
bytecode
(see the EXPLAIN command). It doesn't actually read any data from the database
file (except maybe the schema from sqlite_master).
Dan.


		
__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

 



Re: [sqlite] Row count after prepare

2005-03-15 Thread Dan Kennedy

--- Leif Jensen <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> I'm quite new to SQLite, but like it very much.
> 
>I am trying it out for an existing applicationm which seems good, but 
> I have one problem:
> 
>How do I get the number of rows in the result set after having called 
> sqlite3_prepare( ... ) ? Of course I could call sqlite3_step() until no 
> more rows are returned, but isn't there a better way ?

It can't be done. Calling sqlite3_prepare() just compiles the SQL to bytecode
(see the EXPLAIN command). It doesn't actually read any data from the database
file (except maybe the schema from sqlite_master).

Dan.






__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/