RE: [sqlite] Re: Update current record

2007-12-13 Thread Tom Parke
By a "regular update statement", I assume you mean a SQL update tab set
col = value, but I don't understand how to apply a SQL update statement
to a ROWID.  How can I get the ROWID in the call back?

Can you point me to some sample code that could help me understand?
Tom

-Original Message-
From: Igor Tandetnik [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 13, 2007 5:50 PM
To: SQLite
Subject: [sqlite] Re: Update current record

Tom Parke <[EMAIL PROTECTED]> wrote:
> Using sqlite3_prepare and then sqlite3_step() ing through the records,
> is there a way to update or replace the current record in a table
> while sqlite3_step() is on that record without a reselecting that
> record and sqlite3_exec() update table where?  Something like a
> dynamic cursor in MS SQL?

No. You have to issue a regular update statement using current record's 
ROWID in the WHERE clause.

Igor Tandetnik 



-
To unsubscribe, send email to [EMAIL PROTECTED]

-


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Update current record

2007-12-13 Thread Tom Parke
Using sqlite3_prepare and then sqlite3_step() ing through the records,
is there a way to update or replace the current record in a table while
sqlite3_step() is on that record without a reselecting that record and
sqlite3_exec() update table where?  Something like a dynamic cursor in
MS SQL?

 

Tom



[sqlite] sqlite3_exec() and callback

2007-12-13 Thread Tom Parke
>From what I think I have learned so far, if I call sqlite3_exec() giving
it a call back function and a select * from tbl, I do not have any
direct access to the column values other that the text representation in
the values char array from within the callback()?

 

This leads me to the question, how is the data actually stored in the
file?  

Or

If I use a sqlite3_prepare_v2() and sqlite3_step() and int myvar =
sqlite3_column_int(), am I getting a converted text string?

 

Thanks, I am still trying to get my arms around SQLite.

Tom

 



RE: [sqlite] How to get number of records in record set

2007-12-13 Thread Tom Parke
Thanks, that makes sense. 
Tom

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 13, 2007 7:50 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How to get number of records in record set

"Tom Parke" <[EMAIL PROTECTED]> wrote:
> If I prepare() a sql stmt  SELECT * FROM tbl WHERE col = n:
> 
> How do I find out how many records were selected before calling
step()?
> 

The technically correct response to your question is that the
answer is always zero.  Nothing gets selected - the database
file remains unread - until you call sqlite3_step().  But
that probably is not what you were asking, huh.  :-)

If you want to find out how many records would be selected
by such a query, you can do:

SELECT count(*) FROM tbl WHERE col=n;

Or you can do:

cnt = 1;
while( sqlite3_step()==SQLITE_ROW ) cnt++;

There is no way for the database engine to determine
how many records are going to match your search
condition without actually doing the search and
counting the hits.

--
D. Richard Hipp <[EMAIL PROTECTED]>



-
To unsubscribe, send email to [EMAIL PROTECTED]

-


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] How to get number of records in record set

2007-12-13 Thread Tom Parke
If I prepare() a sql stmt  SELECT * FROM tbl WHERE col = n:

How do I find out how many records were selected before calling step()?


Tom

 

 



[sqlite] Another novice question

2007-12-12 Thread Tom Parke
I created a table with column 1 as primary key.  So where are the index
records?  I thought I would find them in the sqlite_stat1 table but
after inserting records in my table, there are no records in the
sqlite_stat1 table.

 

And, do primary keys need to be the first consecutive n fields?  I
couldn't have a table with only column 3 as primary key could I?

 

Tom



[sqlite] How to get record count

2007-12-12 Thread Tom Parke
How can I get a count of the number of records in a table?
Sqlite3_get_table() might work, but I only need the count, not the
record set.

Thanks,

Tom



[sqlite] sample code

2007-12-11 Thread Tom Parke
Where can I find some sample C code for stepping thru a result set and
for binding variables to columns?  I am just beginning to experiment
with Sqlite3 and I am having a hard time getting aquainted.

Thanks,

Tom