Re: value
От
Dean Rasheed
Тема
Re: value
Дата
Msg-id
AANLkTindjoz5TwijZ+DZtEanCLGQ81Hgu=nPcnVoiYaJ@mail.gmail.com
Ответ на
Re: value (Gissur Þórhallsson)
Список
Дерево обсуждения
value Gissur Þórhallsson <gissur@loftmyndir.is>
Re: value David Fetter <david@fetter.org>
Re: value Gissur Þórhallsson <gissur@loftmyndir.is>
Re: value Dean Rasheed <dean.a.rasheed@gmail.com>
Re: value Gissur Þórhallsson <gissur@loftmyndir.is>
Re: value Dean Rasheed <dean.a.rasheed@gmail.com>
Re: value Gissur Þórhallsson <gissur@loftmyndir.is>
2010/9/16 Gissur Þórhallsson :
>> which is probably not what you might expect.
>
> No, indeed it is not.
> My solution - which seems to be working - is replacing:
> new.my_table_id
> with:
> currval(pg_get_serial_sequence('my_table', 'my_table_id'))
> in the on_insert rule
>
OK, but you still need to be careful. That trick will only work if you
insert rows one at a time into the table. If you have a single insert
that inserts multiple rows (as in my example), it would fail because
the currval() call would return the same value for each row in the
insert created by the rule.
My advice would be to convert to triggers.
Regards,
Dean
> This does the trick.
> Thanks,
> Gissur Þórhallsson
>
> Loftmyndir ehf.
> Laugavegur 13
> IS 101 Reykjavík - Iceland
> sími (tel): (+354) 540 2500
> tölvupóstur (email): gissur@loftmyndir.is
>
В списке pgsql-general по дате отправления