Re: easy way to insert same value into 2 columns - Mailing list pgsql-general

From Sebastian Boeck
Subject Re: easy way to insert same value into 2 columns
Date
Msg-id 3F8E6EE7.4090208@freenet.de
Whole thread Raw
In response to Re: easy way to insert same value into 2 columns  (Csaba Nagy <nagy@ecircle-ag.com>)
Responses Re: easy way to insert same value into 2 columns  (Shridhar Daithankar <shridhar_daithankar@persistent.co.in>)
Re: easy way to insert same value into 2 columns  (Richard Huxton <dev@archonet.com>)
Re: easy way to insert same value into 2 columns  (Jacob Vennervald <jvennervald@proventum.net>)
Re: easy way to insert same value into 2 columns  (Csaba Nagy <nagy@ecircle-ag.com>)
List pgsql-general
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


pgsql-general by date:

Previous
From: Csaba Nagy
Date:
Subject: Re: easy way to insert same value into 2 columns
Next
From: Shridhar Daithankar
Date:
Subject: Re: easy way to insert same value into 2 columns