Re: [SQL] retrieving a serial number

2000-07-02 Thread Joachim Trinkwitz
"Robert B. Easter" <[EMAIL PROTECTED]> writes: > You can do something like this: > $var = SELECT nextval('seq_name'); > INSERT INTO master (id, ...) VALUES ($var, ...); > INSERT INTO slave1 (id, ...) VALUES ($var, ...); Great feaure. What to do when importing some previous data from ascii files

Re: [SQL] retrieving a serial number

2000-06-28 Thread Robert B. Easter
You can do something like this: $var = SELECT nextval('seq_name'); INSERT INTO master (id, ...) VALUES ($var, ...); INSERT INTO slave1 (id, ...) VALUES ($var, ...); ... You can do a \d master, in psql to find out the name of the sequence. For the SERIAL type, nextval('seq_name') is just its defa

Re: [SQL] retrieving a serial number

2000-06-28 Thread Philip Hallstrom
There's probably a way to get that serial number. I think I remember reading that when you specify it as SERIAL, postgresql actually creates a separate sequence. If that's the case then you could do "SELECT currval('mysequence')" -- although I'm not sure what "mysequence" should be set to. The ot

[SQL] retrieving a serial number

2000-06-28 Thread Lea, Michael
I have one table (call it "master") that, among other things, contains a serial number. I have a number of other tables (call them "slaves") that, among other things, contain a foreign key referring to the serial number in the first table. I will be inserting one row into the master table, and one