Re: function and passing the table name to be used with SQL stmnt - Mailing list pgsql-general

From Douglas McNaught
Subject Re: function and passing the table name to be used with SQL stmnt
Date
Msg-id 878x5kso8c.fsf@suzuka.mcnaught.org
Whole thread Raw
In response to Re: function and passing the table name to be used with SQL stmnt  (kamiseq <kamiseq@gmail.com>)
List pgsql-general
kamiseq <kamiseq@gmail.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

pgsql-general by date:

Previous
From: "Catalin Marinas"
Date:
Subject: Re: Fragments in tsearch2 headline
Next
From: paul rivers
Date:
Subject: Re: Partitioning: how to exclude unrelated partitions?