Re: value

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Gissur Þórhallsson <gissur(at)loftmyndir(dot)is>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: value
Date: 2010-09-16 17:04:29
Message-ID: AANLkTindjoz5TwijZ+DZtEanCLGQ81Hgu=nPcnVoiYaJ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/9/16 Gissur Þórhallsson <gissur(at)loftmyndir(dot)is>:
>> 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(at)loftmyndir(dot)is
>

In response to

  • Re: value at 2010-09-16 16:10:11 from Gissur Þórhallsson

Responses

  • Re: value at 2010-09-16 23:44:06 from Gissur Þórhallsson

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2010-09-16 17:22:15 Re: query join issue
Previous Message Bill Thoen 2010-09-16 16:56:43 Re: Need magic for identifieing double adresses