Re: function and passing the table name to be used with SQL stmnt

From: Douglas McNaught <doug(at)mcnaught(dot)org>
To: kamiseq <kamiseq(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: function and passing the table name to be used with SQL stmnt
Date: 2007-10-30 13:53:23
Message-ID: 878x5kso8c.fsf@suzuka.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

kamiseq <kamiseq(at)gmail(dot)com> writes:

> select into _id lastval();
> and is that safe operation, can I rely on lastval() that it will
> return value of id that was inserted before?

You want to use currval() with the sequence name.

> can it happened that other user will insert something between my
> insert and select?

currval() specifically written to be safe in this case.

-Doug

In response to

Browse pgsql-general by date

  From Date Subject
Next Message paul rivers 2007-10-30 13:59:02 Re: Partitioning: how to exclude unrelated partitions?
Previous Message Catalin Marinas 2007-10-30 13:42:25 Re: Fragments in tsearch2 headline