Retrieving the new "nextval" for primary keys....

From: "Greg Patnude" <GPatnude(at)adelphia(dot)net>
To: pgsql-hackers(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Retrieving the new "nextval" for primary keys....
Date: 2002-08-24 01:15:28
Message-ID: ak6lse$a9a$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

I am using postgreSQL with Perl::CGI and Perl::DBI::Pg... I would like to be
able to insert a row from my Perl script [$SQL->exec();] and have postgreSQL
return the id of the newly inserted record (new.id) directly to the Perl
script for further processing... Anyone with a solution / idea ???

Nearly EVERY table I create in postgreSQL (7.2) has the following minimum
structure:

create table "tblName" (

id int4 primary key nextval ("tblName_id_seq"),

..field...
..field...
..field...

create_dt date default 'CURRENT_DATE',
change_dt timestamptz default 'now()',
active_flag bool default 'TRUE'

)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2002-08-24 01:25:52 Re: Controling Rule's Firing Order
Previous Message cn 2002-08-24 01:12:58 Re: Controling Rule's Firing Order

Browse pgsql-sql by date

  From Date Subject
Next Message OU 2002-08-24 19:23:46 Re: SELECT ... WHERE ... NOT IN (SELECT ...);
Previous Message Wei Weng 2002-08-23 19:56:56 Re: question on UPDATE TABLE