Re: Need to check each element of an array satisfies a foreign key constraint

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: David Gauthier <davegauthierpg(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:07:57
Message-ID: CAKFQuwZfnYjT372qenVQsmj4JdpgKrHdzC6iAxEyBc=TvHqH-A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Gauthier 2021-07-13 14:46:56 Re: Need to check each element of an array satisfies a foreign key constraint
Previous Message David Gauthier 2021-07-13 14:00:34 Need to check each element of an array satisfies a foreign key constraint