By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,591 Members | 629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,591 IT Pros & Developers. It's quick & easy.

Error When creating the table

P: 1
When i try to execute this command

CREATE TABLE "public"."tblIterator"("IteratorID" int4 NOT NULL DEFAULT nextval('"tblIterator_IteratorID_seq"'::regclass), "InitializerID" int4 NOT NULL ,"HasNextID" int4 NOT NULL ,PRIMARY KEY ("IteratorID"),FOREIGN KEY ("HasNextID") REFERENCES "public"."tblCode"("CodeID") ON UPDATE RESTRICT ON DELETE CASCADE ,FOREIGN KEY ("InitializerID") REFERENCES "public"."tblCode"("CodeID") ON UPDATE RESTRICT ON DELETE CASCADE ,UNIQUE ("HasNextID") ,UNIQUE ("InitializerID")) WITHOUT OIDS;

When i remove the "DEFAULT nextval('"tblIterator_IteratorID_seq"'::regclass)"
it works.

What am I doing wrong? Why does the "nextval" throw an error ?

I will really appreciate your help.
Feb 8 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 534
It could help if you posted the error you're getting...

Unless in the latest versions the sequence is created 'on-demand', I suspect you may see something like this:

ERROR: Relation "tblIterator_IteratorID_seq" does not exist

If this is the case you may want to change
IteratorID int4 NOT NULL DEFAULT nextval (...
IteratorID serial not null,
this will automatically create sequence <tabname>_<colname>_seq

Also make sure you really want those double-quotes around the table and field namjes. Making your database case-sensitive hurts way more often than it helps.
Feb 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.