Two DB questions

Jan Schenkel janschenkel at yahoo.com
Thu Oct 23 07:55:08 EDT 2008


--- Klaus Major <klaus at major-k.de> wrote:
> Hi all,
> 
> 1. One can move to the first/prev/next/last record
> in a DB cursor  
> with: revdb_moveXXX(Cursor_ID)
> Is it also possible to go to a specific record
> NUMBER? Maybe I  
> overlooked this in the docs...
> 

Nope, you have to look at revdb_currentrecord() to
figure out where you're at, and then repeatedly call
revdb_moveprev() or revdb_movenext().

> 2. Since I cannot test it in the moment, how can one
> check if an  
> existing table does NOT contain any data/records
> (yet)?
> I presume one can get a db cursor first and then
> check  
> "revdb_recordcount" = 0.
> Is that correct?
> 

Depending on the database, you could look at its
internal statistics system tables, but this is very
DBMS-specific.

You can't have a cursor without a SELECT query, so
what you could do is something like
##
put revdb_query(tConnection, "SELECT * FROM
customers") into tCursor
put revdb_recordcount(tCursor) into tRecordCount
##
but depending on the DBMS, this may lock the entire
table (as it's not going to make a copy of the entire
table just so that you can traverse it at leisure
while others make changes or delete records)

So if you're only interested in learning if there's
any data in the table, and if your DBMS supports it,
you should use a LIMIT or TOP clause in your SELECT
query to make sure you only get the first record if
there is one.

> Thanks a lot in advance!
> 
> 
> Best
> 
> Klaus Major
> 

HTH,

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


      



More information about the use-livecode mailing list