From: | Jason Hihn <jhihn(at)paytimepayroll(dot)com> |
---|---|
To: | "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk> |
Cc: | Richard Huxton <dev(at)archonet(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Help with array constraints |
Date: | 2003-04-03 17:11:52 |
Message-ID: | NGBBLHANMLKMHPDGJGAPGEGOCGAA.jhihn@paytimepayroll.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org]On Behalf Of Nigel J. Andrews
> Sent: Thursday, April 03, 2003 11:19 AM
> To: Jason Hihn
> Cc: Richard Huxton; pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Help with array constraints
>
>
> On Thu, 3 Apr 2003, Jason Hihn wrote:
> You probably want to write your own function(s) and install it(them) as
> trigger(s).
>
> create function letter_fk () returns trigger as '
> declare
> ind integer;
> begin
> for ind in array_dims(NEW.letters) loop
> perform 1 from _test where id = NEW.letters[ind];
> if not found then
> raise exception ''My foriegn key constraint
> violation'';
> end if;
> end loop;
>
> return NEW;
> end;
> ' as language 'plpgsql';
>
> create trigger my_array_fkey
> before insert
> on test
> for each row execute procedure letter_fk();
>
>
> Or something like that anyway. Also that's only a start.
Ah that's more like what I'm looking for. I have to attempt a select of the
new letter in the contrainted-to table. If it finds it, success! If the
contrainted-to table has an index, it should be very fast no matter how many
letters it's being constrained against...
"SELECT NEW.letter FROM constraint_table WHERE letter=id"
if null set raise exception.
I would have thought this would be built in? Can it be?
From | Date | Subject | |
---|---|---|---|
Next Message | scott.marlowe | 2003-04-03 17:15:42 | Re: Postgresql capabilities question |
Previous Message | Nigel J. Andrews | 2003-04-03 16:18:43 | Re: Help with array constraints |