Re: PL/pgSQL compatibility?

From: Soma Interesting <dfunct(at)telus(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: PL/pgSQL compatibility?
Date: 2000-12-09 00:29:09
Message-ID: 5.0.0.25.0.20001208154613.02fc9300@pop.telus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 06:29 PM 12/8/2000 -0500, you wrote:

You understood perfectly what I was trying to express and your answer
helped lots.

> > And going in the other direction. When time comes to add a child
>row,
> > can the DBMS be setup to manage the necessary relations rows
>and
> > parent rows? I'd imagine I would need triggers to accomplish this -
>as
> > I don't think there is such a thing as a CASCADE INSERT :)
>
>There is no CASCADE INSERT. The rules for INSERT are
>straightforward. You can't add a StudentClass if there isn't a
>referenced Class and a referenced Student (pending DEFERRED; see
>the draft tutorial for info on that.)
>
>If that's not what you want, what exactly do you want to manage
>about the relationship?

In the case of what I'm working on, I'll want to just add a row to
ClassStudent and it will automatically make corresponding semi-blank rows
in Student and Class based on the id's I inserted into ClassStudent. So I
would need to use a trigger for this also. I guess I was wondering if I
could get referential integrity to handle both the trigger you suggested
above and the trigger I'm suggesting - which isn't what referential
integrity is intended for.

In the context of what I'm working on, the related Student rows won't
always exist already and I'm trying to avoid writing PHP code to handle
Inserting a new class row, and inserting the user's requested number of
blank student rows, then inserting the corresponding rows in ClassStudent.

I can't really use a trigger because sometimes existing students will be
added to a class. In which case inserting the appropriate row would set off
the trigger, creating unwanted blank class and student rows.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Barry Lind 2000-12-09 00:55:43 Bug in index scans with Locale support enabled
Previous Message Tom Lane 2000-12-09 00:08:50 Re: How do I remove a foreign key constraint?