Re: UPDATE/INSERT on multiple co-dependent tables - Mailing list pgsql-sql

From Karsten Hilbert
Subject Re: UPDATE/INSERT on multiple co-dependent tables
Date
Msg-id 20041114094724.J568@hermes.hilbert.loc
Whole thread Raw
In response to UPDATE/INSERT on multiple co-dependent tables  (Ferindo Middleton Jr <fmiddleton@sleekcollar.com>)
List pgsql-sql
> 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


pgsql-sql by date:

Previous
From: "Contact AR-SD.NET"
Date:
Subject: Re: upper/lower for german characters
Next
From: Theodore Petrosky
Date:
Subject: Re: postgreSQL 8beta