Re: easy way to insert same value into 2 columns

Поиск
Список
Период
Сортировка
От Csaba Nagy
Тема Re: easy way to insert same value into 2 columns
Дата
Msg-id 1066303298.10511.44.camel@coppola.ecircle.de
обсуждение исходный текст
Ответ на Re: easy way to insert same value into 2 columns  (Sebastian Boeck <sebastianboeck@freenet.de>)
Ответы Re: easy way to insert same value into 2 columns
Список pgsql-general
I can't 100% say it's safe to use, but no, other inserts will not
influence the value, because currval will return the last sequence value
used by the current session (i.e. the current connection). And of course
you only have concurrent inserts using different connection, right ?

HTH,
Csaba.


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



В списке pgsql-general по дате отправления:

Предыдущее
От: Sebastian Boeck
Дата:
Сообщение: Re: easy way to insert same value into 2 columns
Следующее
От: Jean-Michel POURE
Дата:
Сообщение: Maping Oracle nvarchar2(lenght) to PostgreSQL varchar(lenght)