Primary Key with auto increment field - Mailing list pgsql-general

From x asasaxax
Subject Primary Key with auto increment field
Date
Msg-id 91495cb0804011543n7f35f880ud691fa8f30bbe505@mail.gmail.com
Whole thread Raw
Responses Re: Primary Key with auto increment field  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
I would like to increment one field, depending of the value of the other. here´s an example:

id variable
1 1
2 1
1 2
2 2

can i do that with the following commands?

SELECT setval('sequence',(SELECT max(id) FROM table)) INTO variable;
insert into table values(variable, ..., ...); ?

Will this be transactional? Cause, they say that setval is a command that its transactional. Using this way i

don´t will need to use a sequence anymore. Is that correct?


Thanks you all.

pgsql-general by date:

Previous
From: carty mc
Date:
Subject: dblink ,dblink_exec not participating in a Transaction??
Next
From: carty mc
Date:
Subject: Re: dblink ,dblink_exec not participating in a Transaction??