From: | Dror Matalon <dror(at)zapatec(dot)com> |
---|---|
To: | sfpug(at)postgresql(dot)org |
Subject: | Re: Best practices? |
Date: | 2003-10-01 05:53:28 |
Message-ID: | 20031001055328.GL87525@rlx11.zapatec.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | sfpug |
Also,
For those of us, the imagination challenged :-), can you provide a real world
example of when you need to implement this?
Dror
On Tue, Sep 30, 2003 at 10:38:48PM -0700, Josh Berkus wrote:
> Dave,
>
> > At the end of any transaction involving foo (including INSERT), a foo
> > must have between m and n bars.
> >
> > Is there a standard way to approach this?
>
> Not a good way, no. What you need is a constraint, or a BEFORE trigger, that
> only fires once at the end of each transaction. Even with the statement
> triggers coming in 7.4, we don't have that.
>
> Using VIEWs backed by RULEs won't work either, becuase if N is 2 and M is 5,
> you need to insert at least 3 bars for each foo in any statement, an
> impossibility in SQL.
>
> (FWIW, such constraints are one of the major failings of the SQL standard ...
> they are easy to implement in relational calculus, but can only be done
> procedurally in SQL)
>
> Unfortunately, I think you're facing using "data-push" functions, where
> instead of "insert into foo; insert into bar" you call fn_insert_foo ( foo1,
> foo2, {barA1, barA2}, {barB1, barB2});
>
> --
> Josh Berkus
> Aglio Database Solutions
> San Francisco
--
Dror Matalon, President
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com
From | Date | Subject | |
---|---|---|---|
Next Message | elein | 2003-10-01 17:28:35 | Re: Best practices? |
Previous Message | Josh Berkus | 2003-10-01 05:40:19 | Desperately seeking office space |