Re: pl/pgSQL sequence question - Mailing list pgsql-novice

From Tom Lane
Subject Re: pl/pgSQL sequence question
Date
Msg-id 18539.1072130892@sss.pgh.pa.us
Whole thread Raw
In response to pl/pgSQL sequence question  ("Stephen Shorrock" <smsh@bas.ac.uk>)
List pgsql-novice
"Stephen Shorrock" <smsh@bas.ac.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

pgsql-novice by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: data/index file size info
Next
From: Tom Lane
Date:
Subject: Re: Incorrect (?) escape of the $1