[SQL] fetching the id of a new row

2001-02-08 Thread Jelle Ouwerkerk

Hi,

How might I insert a new row into a table and return the id of the new row
all in the same SQL statement? The id is generated by a sequence. Up to
now I've been getting the nextval of the sequence first and then inserting
with the id in a second SQL exec. Is there a faster way (in a general
case, without writing SQL or plpgsql functions)?

Thanks






[SQL] random

2001-03-05 Thread Jelle Ouwerkerk

Hi

What would be the best way to select a random row from a result set?

Possibilities:

1) o get the total number of rows using count()
   o generate a random number between 1 and the total
   o select the n'th row using OFFSET

2) o get the total number of rows using count()
   o generate a random number between 1 and the total
   o fetch n times

Option 1 uses 'OFFSET' which is a database-specific keyword, which is
probably bad. 

Also, is there a way to randomize the order of a result set?

Thanks in advance

Jelle Ouwerkerk
Software Developer 
Openface Internet Inc.
Montreal, Quebec, Canada
http://www.openface.ca


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])