in reply to Working with Postgresql serial data type in Perl

If you want to enter a specific integer, just pass it on to the database.

If not, construct your query in a way that simply doesn't enter any value for the serial column. For example if the table has columns id and name, and id is serial, simply write something like

my $sth = $dbh->prepare('INSERT INTO your_table(name) VALUES (?)'); $sth->execute($your_name);

Replies are listed 'Best First'.
Re^2: Working with Postgresql serial data type in Perl
by vendion (Scribe) on Dec 18, 2010 at 21:16 UTC

    the integer that gets used doesn't matter to me it just has to be unique for each entry. I have not thought about not passing anything to anything to that column in the database.

      It's all in the excellent manual: datatype serial (also available in PDF )

      Note that:

      Prior to PostgreSQL 7.3, serial implied UNIQUE. This is no longer automatic. If you wish a serial column to have a unique constraint or be a primary key, it must now be specified, just like any other data type.

      (Btw: a hint regarding the database name: call it postgresql, postgres, or even Pg, but calling it 'Postgre' makes the same impression as writing PERL instead of Perl).

        Thanks for the help and also thanks for that hint, I will try to keep it in mind in the future.