Two DB questions
Len Morgan
len-morgan at crcom.net
Thu Oct 23 23:33:43 EDT 2008
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. 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.
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.
len morgan
More information about the use-livecode
mailing list