pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: jrbeckstrom@voyager.net
To: pgsql-php@postgresql.org
Subject: Re: Use of Serial type
Date: Wed, 18 Sep 2002 16:08:14 -0700
Message-ID: <200209181608.14039.josh@agliodbs.com> (raw)
In-Reply-To: <3D88C991.54BF238E@voyager.net>
References: <3D88C991.54BF238E@voyager.net>

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




view thread (6+ messages)  latest in thread

Message-ID: <200209181608.14039.josh@agliodbs.com>
Permalink:  ../200209181608.14039.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200209181608.14039.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: josh@agliodbs.com, jrbeckstrom@voyager.net
  Subject: Re: Use of Serial type
  In-Reply-To: <200209181608.14039.josh@agliodbs.com>
  References: <3D88C991.54BF238E@voyager.net> <200209181608.14039.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox