Re: FAQ error - Mailing list pgsql-hackers

From Alessio Bragadini
Subject Re: FAQ error
Date
Msg-id 3BC58318.CB0828DB@albourne.com
Whole thread Raw
In response to FAQ error  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian wrote:

>         $newSerialID = nextval('person_id_seq');
>         INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise Pascal');
> 
> Is this correct Perl?  I don't see a nextval() function in Perl.  Can
> you call SQL server-side functions natively from Perl?

Ofcourse not. This can be counted as 'pseudo-code'...

A correct implementation using DBI (and DBD::Pg) would be

$newSerialID = $dbh->selectrow_array (q{select
nextval('person_id_seq')});
$dbh->do (qq{INSERT INTO person (id, name) VALUES ($newSerialID, 'Blaise
Pascal')});

-- 
Alessio F. Bragadini        alessio@albourne.com
APL Financial Services        http://village.albourne.com
Nicosia, Cyprus             phone: +357-2-755750

"It is more complicated than you think"    -- The Eighth Networking Truth from RFC 1925


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: iso-8859-15/16 to MULE
Next
From: Michael Meskes
Date:
Subject: Deadlock? idle in transaction