| From: | Michael Schmidt <MichaelMSchmidt(at)msn(dot)com> |
|---|---|
| To: | Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> |
| Cc: | Alain Roger <raf(dot)news(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: sequence |
| Date: | 2007-12-10 00:20:30 |
| Message-ID: | BAYC1-PASMTP1247DFBB86BF2D9AC2323AA36B0@CEZ.ICE |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Another option is to set the default value of the field to the nextval,
such as for mytable primary key field
nextval(('public.users_user_id_seq'::text)::regclass). Then, when you
write your SQL
INSERT INTO mytable VALUES(default). I do it this way and find it a
little cleaner. If you want to access the users_user_id_seq value
within the same transaction, then after the insert into mytable you can
use currval.
Michael Schmidt
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Brian Herlihy | 2007-12-10 01:43:12 | Log statement length limit |
| Previous Message | x asasaxax | 2007-12-09 19:34:50 | Problems with acessing xml functions on other database |