From: | David Gauthier <davegauthierpg(at)gmail(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Need to check each element of an array satisfies a foreign key constraint |
Date: | 2021-07-13 14:46:56 |
Message-ID: | CAMBRECDFpwpK0nHn-5XuO6pjB0cfieSryaBHMLtqPKQV-4Qhhg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ok, thanks.
I was looking for, but didn't find, something like...
each_element_of(regexp_split_to_array(children_csv)) references
projects(project);
Of course the "each_element_of" is my creation here :-)
On Tue, Jul 13, 2021 at 10:07 AM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Tuesday, July 13, 2021, David Gauthier <davegauthierpg(at)gmail(dot)com>
> wrote:
>>
>>
>> I suppose I could write a stored procedure to do this and call it in a
>> check constraint. But I was wondering if there is something more elegant.
>>
>>
> You cannot use a check constraint here as the behavior is not immutable.
> You can use a trigger function though. Or normalize the table and use the
> built-it foreign key triggers.
>
> David J.
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Shepard | 2021-07-13 17:29:43 | psycopg2 mail list subscription issues |
Previous Message | David G. Johnston | 2021-07-13 14:07:57 | Re: Need to check each element of an array satisfies a foreign key constraint |