Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3D110476390 for ; Thu, 19 Dec 2002 04:34:41 -0500 (EST) Received: from stan.ringways.co.uk (hub.ringways.co.uk [213.38.87.130]) by postgresql.org (Postfix) with ESMTP id D026D475EFD for ; Thu, 19 Dec 2002 04:34:23 -0500 (EST) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with esmtp (Exim 3.22 #1) id 18Ox35-0001Vd-00; Thu, 19 Dec 2002 09:32:59 +0000 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: Tom Lane Subject: Re: references table(multiple columns go here) Date: Thu, 19 Dec 2002 09:28:19 +0000 User-Agent: KMail/1.4.3 Cc: Tomasz Myrta , pgsql-sql@postgresql.org References: <200212181625.11316.gary.stainburn@ringways.co.uk> <200212181718.42870.gary.stainburn@ringways.co.uk> <8026.1040233829@sss.pgh.pa.us> In-Reply-To: <8026.1040233829@sss.pgh.pa.us> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200212190928.19736.gary.stainburn@ringways.co.uk> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/231 X-Sequence-Number: 10819 Thanks for that Tom On Wednesday 18 Dec 2002 5:50 pm, Tom Lane wrote: > Gary Stainburn writes: > > I've just tried this on a 7.2.1-5 system and get the same error. > > > >> create table jobtypes ( > >> jid int4 default nextval('jobs_jid_seq'::text) unique not null, > >> jdid character, -- This joint reference > >> jrank int4 not null references ranks(rrank), -- needs sorting > >> jdesc character varying(40), -- job description > >> contraint c2 foreign key (jdid,jrank) references ranks (rdid,rrank) > > ^^^^^^^^^ > > >> ); > >> ERROR: parser: parse error at or near "foreign" > > If that's an accurate transcription, I think "contraint" -> "constraint" > would help... > That did the trick. However, I now have another problem with the constraint complaining about there not being an index to refer to. However, there is. Output below: create table ranks ( rid int4 default nextval('ranks_rid_seq'::text) unique not null, rdid character references depts(did), -- department rrank int4 not null, -- departmental rank rdesc character varying(40) -- Rank Description ); NOTICE: CREATE TABLE/UNIQUE will create implicit index 'ranks_rid_key' for table 'ranks' NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) CREATE create unique index "ranks_drank_index" on ranks using btree ("rdid", "rrank"); CREATE create table jobtypes ( jid int4 default nextval('jobs_jid_seq'::text) unique not null, jdid character, -- This joint reference jrank int4 not null references ranks(rrank), -- needs sorting jdesc character varying(40), -- job description constraint c2 foreign key (jdid,jrank) references ranks (rdid,rrank) ); NOTICE: CREATE TABLE/UNIQUE will create implicit index 'jobtypes_jid_key' for table 'jobtypes' NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) ERROR: UNIQUE constraint matching given keys for referenced table "ranks" not found > regards, tom lane -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000