Re: Trigger/Function Problem

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: <kowal(at)nawigator(dot)pl>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Trigger/Function Problem
Date: 2001-02-12 21:08:59
Message-ID: Pine.LNX.4.30.0102122205320.1100-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

kowal(at)nawigator(dot)pl writes:

> Table "mp3user"
> Attribute | Type | Modifier
> --------------+-------------+--------------------------------------------------
>
> id | integer | not null default
> nextval('mp3user_id_seq'::text)
> nick | varchar(20) |
>
> Table "mp3user_data"
> Attribute | Type | Modifier
> ------------+-------------+----------------------
> id | integer | not null
> imie | varchar(30) | not null
> nazwisko | varchar(30) | not null
>
> I have to table looking like the above (only bigger).
>
> What I want to do I to set a trigger which ON DELETE from "mp3user"
> table
> will automatically DELETE a row from "mp3user_data" table.

Looks like you want to use a foreign key. Declare your mp3user_data table
something like this:

CREATE TABLE mp3user_data (
id integer references mp3user on delete cascade,
...
);

See http://www.postgresql.org/users-lounge/docs/7.0/user/sql-createtable.htm
for details.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2001-02-12 21:10:27 Re: ALTER DROP COLUMN
Previous Message J.H.M. Dassen Ray 2001-02-12 20:54:49 Re: PostgreSQL vs Oracle vs DB2 vs MySQL - Which should I use?