Re: Use of Serial type

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: jrbeckstrom(at)voyager(dot)net, pgsql-php(at)postgresql(dot)org
Subject: Re: Use of Serial type
Date: 2002-09-18 23:08:14
Message-ID: 200209181608.14039.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Jim,

> Using php, I create a table with a SERIAL field. In the same
> script, the last thing I do is a COPY ... FROM ... USING DELIMITERS...to
> load data I have outputted from another system into a text delimited
> file. I didn't get the autoincrementing of the serial field to work, so
> I modified my output-from-another-system program to "manually" set the
> serial field value. That worked. However, it does not seem to have
> done a default SETVAL. Do I do a "manual" SETVAL of 1 greater than the
> highest value from the input text file, or am I missing something in the
> create and copy process?

That sounds fine. However, I would bundle everything in a transaction to be
safe. Otherwise, you risk having a user access the table without the serial
value correctly set.

--
-Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Warren Massengill 2002-09-18 23:17:15 Use of Serial type
Previous Message Papp Gyozo 2002-09-18 22:48:24 Re: Use of Serial type