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