Re: FAQ error

From: Alessio Bragadini <alessio(at)albourne(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: FAQ error
Date: 2001-10-11 11:31:36
Message-ID: 3BC58318.CB0828DB@albourne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)albourne(dot)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

In response to

  • FAQ error at 2001-10-10 21:12:06 from Bruce Momjian

Browse pgsql-hackers by date

  From Date Subject
Next Message Alex Pilosov 2001-10-11 14:11:42 Re: Suitable Driver ?
Previous Message Michael Meskes 2001-10-11 09:28:30 Deadlock? idle in transaction