Re: pg newbie stumped on sequences!

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: "Ben Joyce" <ben(dot)joyce-pgsql(at)babelfish(dot)co(dot)uk>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg newbie stumped on sequences!
Date: 2003-05-20 16:54:13
Message-ID: m31xyt5zka.fsf@varsoon.wireboard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Ben Joyce" <ben(dot)joyce-pgsql(at)babelfish(dot)co(dot)uk> writes:

> Hi. I'm from a MSSQL/mySQL background and am just poking about in PG.
> I'm using phpPgAdmin 2.3 and PostgreSQL 7.1.3.
>
> INSERT INTO "test" ("ID", "Subject", "Body", "DTS", "Archive") VALUES
> (NEXTVAL('""test_ID_seq""'::text), 'test', 'this is a test', '2003-05-20
> 16:30:42', '0')

This is wrong--the "nextval" call should look like:

NEXTVAL('"test_ID_seq"')

The '::text' cast is optional but shouldn't hurt anything.

Looks like phpPgAdmin is inserting too many quotes.

FYI: the double-quotes-within-single-quotes thing is to tell NEXTVAL
not to fold the sequence name to lower case (which it would do if you
left out the double quotes). Yes, it's a little odd. ;)

'

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike Benoit 2003-05-20 17:06:01 Re: disk space usage enlarging despite vacuuming
Previous Message Stefano Vita Finzi 2003-05-20 16:52:14 plpgsql recursion