Re: pl/pgSQL sequence question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Stephen Shorrock" <smsh(at)bas(dot)ac(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: pl/pgSQL sequence question
Date: 2003-12-22 22:08:12
Message-ID: 18539.1072130892@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Stephen Shorrock" <smsh(at)bas(dot)ac(dot)uk> writes:
> createtable := ''CREATE TABLE debugtab(idcol INTEGER PRIMARY KEY DEFAULT NEXTVAL(tmp_seq), value int )'';

> --why can it not find tmp_seq??

You need quotes. For mostly historic reasons, nextval takes a string
argument containing the name of the sequence, which is not what you
wrote here.

You could avoid messing directly with the sequence if you defined the
column as "idcol SERIAL PRIMARY KEY", instead.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-12-22 22:16:24 Re: Incorrect (?) escape of the $1
Previous Message Bruce Momjian 2003-12-22 21:14:36 Re: data/index file size info