X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8D0463A4C58 for ; Sun, 14 Nov 2004 09:00:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 15744-07 for ; Sun, 14 Nov 2004 09:00:19 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 25E313A4C68 for ; Sun, 14 Nov 2004 09:00:17 +0000 (GMT) Received: (qmail 624 invoked by uid 65534); 14 Nov 2004 09:00:16 -0000 Received: from p5087FAA4.dip0.t-ipconnect.de (EHLO hermes.hilbert.loc) (80.135.250.164) by mail.gmx.net (mp016) with SMTP; 14 Nov 2004 10:00:16 +0100 X-Authenticated: #1433807 Received: (from ncq@localhost) by hermes.hilbert.loc (8.11.6/8.11.6/SuSE Linux 0.5) id iAE8lOZ10739 for pgsql-sql@postgresql.org; Sun, 14 Nov 2004 09:47:24 +0100 Date: Sun, 14 Nov 2004 09:47:24 +0100 From: Karsten Hilbert To: pgsql-sql Subject: Re: UPDATE/INSERT on multiple co-dependent tables Message-ID: <20041114094724.J568@hermes.hilbert.loc> References: <1100053572.9414.142.camel@scnmaster.sleekcollar.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1100053572.9414.142.camel@scnmaster.sleekcollar.com> User-Agent: Mutt/1.3.22.1i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/135 X-Sequence-Number: 19454 > Is it possible for an UPDATE/INSERT query string to function in such a > way that it requires two like fields in different tables to be equal > to/'in sync with' one another: > > Example: I have two tables: registration & schedules.... > they both record a class_id, start_date, end_date... I want to make > sure that if the schedule_id field is updated in the registration table; > that class_id, start_date & end_date fields automatically change to > match the schedules.id record in the schedules table.... Sounds like you want a foreign key with ON UPDATE CASCADE. If that doesn't work for some reason or other you might be able to achieve what you need with an explicit trigger on update of registration.schedule_id. Karsten -- GPG key ID E4071346 @ wwwkeys.pgp.net E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346