dbTalk Databases Forums  

Re: pl/pgSQL sequence question

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss Re: pl/pgSQL sequence question in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Lane
 
Posts: n/a

Default Re: pl/pgSQL sequence question - 12-22-2003 , 04:08 PM






"Stephen Shorrock" <smsh (AT) bas (DOT) ac.uk> writes:
Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match



Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: pl/pgSQL sequence question - 01-08-2004 , 11:38 AM






"Stephen Shorrock" <smsh (AT) bas (DOT) ac.uk> writes:
Quote:
Thanks for your response Tom,
I thought that you might like to know I've implemented you idea of using idcol SERIAL PRIMARY KEY, which is a really good tip. Although not in a function as I am unable to remove this durring the function call:
ERROR: RelationForgetRelation: relation 47527448 is still open
I think this could only happen in pre-7.3 Postgres. Consider updating.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.