From: | Jacob Vennervald <jvennervald(at)proventum(dot)net> |
---|---|
To: | Sebastian Boeck <sebastianboeck(at)freenet(dot)de> |
Cc: | Postgres general mailing list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: easy way to insert same value into 2 columns |
Date: | 2003-10-16 10:53:40 |
Message-ID: | 1066301620.1092.26.camel@jvennervald.intra.proventum.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> Thanks a lot, but is it save to use?
>
> Do i always get the same value, even if an other insert is changing
> the sequence >public.zeit_id_seq< just at the same time?
Yes. currval() gives you the last id of the sequence in your session.
So if others log in and insert more rows it wont affect your session.
Can I ask why you would wanna do that anyway?
Jacob
On Thu, 2003-10-16 at 12:11, Sebastian Boeck wrote:
> Csaba Nagy wrote:
> > For your specific question I don't know the answer.
> >
> > For this particular case you could use:
> >
> > create table your_table (
> > id integer default nextval ('public.zeit_id_seq'::text),
> > pos_id integer default currval ('public.zeit_id_seq'::text),
> > ...
> > );
> >
> > That would work fine as long as you use inserts which don't specify id
> > if pos_id is not specified (otherwise the currval will throw you an
> > error cause it cannot be called without nextval being called).
> >
> > HTH,
> > Csaba.
>
> Thanks a lot, but is it save to use?
>
> Do i always get the same value, even if an other insert is changing
> the sequence >public.zeit_id_seq< just at the same time?
>
> Regards
>
> Sebastian
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>
--
Venlig hilsen / Best regards,
Jacob Vennervald
System Developer
Proventum Solutions ApS
Tuborg Boulevard 12
2900 Hellerup
Denmark
Phone: +45 36 94 41 66
Mobile: +45 61 68 58 51
From | Date | Subject | |
---|---|---|---|
Next Message | Sebastian Boeck | 2003-10-16 11:03:57 | Re: easy way to insert same value into 2 columns |
Previous Message | Richard Huxton | 2003-10-16 10:51:19 | Re: easy way to insert same value into 2 columns |