Description: Mysql has it, why doesn't PG? This lets you do the same thing.
This is not a code exactly, code it yourself:
create sequence x_seq;
create table x(
a int4 not null default nextval('x_seq'),
create unique index x_pk on x(a);
first execute a query and get result:
$x=value_of_this("select nextval('x_seq') as x"); //will not work if you copy paste it
then exec full sql:
insert into x values($x, 'somedata');
use $x ...