Two DB questions

Klaus Major klaus at major-k.de
Fri Oct 24 03:29:23 EDT 2008


Hi Len,

> Klaus,
>
> It seems that you come from an "old fashioned" DB background (i.e.,  
> dBaseII, etc) where the idea of a record number meant something.

Actually I come form nowhere (database wise) :-D

And I really do not care about record numbers, I only want to display  
something like
"Record x of Y" on the card while he is browsing through the data,  
since this the info
that I would like to see, too.

And I want to "sync" this display after a new cursor has been fetched.
Know what I mean?

> If you read up on the history of SQL, you'll see that one of reasons  
> for SQL was to get rid of the concept of a record number.  In fact  
> when you join two or more tables, what would the "record number"  
> represent since the "table" that you are returning doesn't actually  
> exist in the database (it's created on the fly).
> However, there IS a way that Revolution is particularly good at:   
> Return your records as a list (as opposed to a record set) and then  
> go to the line number (which becomes the record number) and use  
> "items" to get at the various fields.  As long as your returned data  
> isn't too large, it should be very fast.

Since I do not know how large the possible data is, I tend to create  
generic handlers.
That's why I prefer cursors instead of the "real" data.

> As to your second question (how do you know if a table has any data  
> in it), I've always used SQL to give me that answer:
>
> SELECT COUNT(*) FROM mytable
>
> Any SQL database worthy of the name should have at least this  
> aggregate function.  PostgreSQL at least, doesn't require the "GROUP  
> BY" clause with COUNT(*) and I suspect others would be the same.  If  
> the record count is 0, there hasn't been any data entered.  It won't  
> choke if there are no tables since in this case, zero is a valid  
> answer.

Ah, great, that is a very useful hint, thanks a lot!

> len morgan

Best

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





More information about the use-livecode mailing list