pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karsten Hilbert <Karsten.Hilbert@gmx.net>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: UPDATE/INSERT on multiple co-dependent tables
Date: Sun, 14 Nov 2004 09:47:24 +0100
Message-ID: <20041114094724.J568@hermes.hilbert.loc> (raw)
In-Reply-To: <1100053572.9414.142.camel@scnmaster.sleekcollar.com>
References: <1100053572.9414.142.camel@scnmaster.sleekcollar.com>

> 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



view thread (4+ messages)

Message-ID: <20041114094724.J568@hermes.hilbert.loc>
Permalink:  ../20041114094724.J568@hermes.hilbert.loc/
Also on:    postgresql.org/message-id/20041114094724.J568@hermes.hilbert.loc

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Karsten.Hilbert@gmx.net
  Subject: Re: UPDATE/INSERT on multiple co-dependent tables
  In-Reply-To: <20041114094724.J568@hermes.hilbert.loc>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox