Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 976FE476AF1 for ; Wed, 18 Dec 2002 12:04:43 -0500 (EST) Received: from stan.ringways.co.uk (hub.ringways.co.uk [213.38.87.130]) by postgresql.org (Postfix) with ESMTP id AF3C8476B5B for ; Wed, 18 Dec 2002 12:02:06 -0500 (EST) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with esmtp (Exim 3.22 #1) id 18OhYq-0005Zl-00; Wed, 18 Dec 2002 17:00:44 +0000 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: Tomasz Myrta Subject: Re: references table(multiple columns go here) Date: Wed, 18 Dec 2002 16:56:13 +0000 User-Agent: KMail/1.4.3 Cc: pgsql-sql@postgresql.org References: <200212181625.11316.gary.stainburn@ringways.co.uk> <3E00A678.5070605@klaster.net> In-Reply-To: <3E00A678.5070605@klaster.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200212181656.13432.gary.stainburn@ringways.co.uk> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/226 X-Sequence-Number: 10814 Hi Tomasz, On Wednesday 18 December 2002 4:46 pm, Tomasz Myrta wrote: > Hello again > > Gary Stainburn wrote: > > Hi folks, > > > > how do I define a referene from 2 columns in 1 table to 2 columns in > > another. > > > > I have: > > > > 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 > > ); > > > > > > > > > > I would now like to define the following table so that inserts can > > only happen > > if jdid matches rdid and jrank matches rrank. > > > > create table jobtypes ( > > jid int4 default nextval('jobs_jid_seq'::text) unique not null, > > jdid character references ranks(rdid), -- This joint reference > > jrank int4 not null references ranks(rrank), -- needs sorting > > jdesc character varying(40) -- job description > > !!!here!!! ,CONSTRAINT c2 FOREIGN KEY(jid,jdid) REFERENCES ranks (rid,rdid) Did this come in with 7.2? I get parse error on or near 'FOREIGN'. Note I changed the field names to the ones I wanted. 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" > > > ); > > that's all > Tomasz Myrta -- 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