Two DB questions

Klaus Major klaus at major-k.de
Thu Oct 23 08:08:44 EDT 2008


Hi Jan,

> --- 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().

I was afraid of that :-)

>> 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.

I try to avoid DB specific things!

> 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
> ##

Yep, that's what I thought of.

> 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.

See above, I'd like to stick to "pure" SQL.

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

Thanks a lot, Jan!


Best

Klaus Major
klaus at major-k.de
http://www.major-k.de





More information about the use-livecode mailing list