Deferrerable Check constraints
Deferrerable Check constraints
От:
"Luiz K. Matsumura" <luiz@planit.com.br>
Дата:
Hi All, Need a Help. Can a check constraint be deferred until the end of a transaction ? In other words, if i have a constraint like this: CREATE TABLE test ( id serial NOT NULL, qt1 integer NOT NULL DEFAULT 0, qt2 integer NOT NULL DEFAULT 0, CONSTRAINT check_qt CHECK (qt1 <= qt2) ) There are some manner that allow qt1 to be greater than qt2 on a intermediate state of the transaction ? Thanks in Advance -- Luiz K. Matsumura Plan IT Tecnologia Informática Ltda.
Re: Deferrerable Check constraints
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Luiz K. Matsumura" writes: > Need a Help. Can a check constraint be deferred until the end of a > transaction ? Nope, sorry. If you're desperate to have such functionality you could check the condition in a "constraint trigger". http://www.postgresql.org/docs/8.3/static/sql-createconstraint.html regards, tom lane
Re: Deferrerable Check constraints
От:
Bruce Hyatt <brucejhyatt@yahoo.com>
Дата:
--- On Mon, 11/24/08, Luiz K. Matsumura wrote:
> Hi All,
>
> Need a Help. Can a check constraint be deferred until the
> end of a transaction ?
> In other words, if i have a constraint like this:
>
> CREATE TABLE test
> (
> id serial NOT NULL,
> qt1 integer NOT NULL DEFAULT 0,
> qt2 integer NOT NULL DEFAULT 0,
> CONSTRAINT check_qt CHECK (qt1 <= qt2)
> )
>
> There are some manner that allow qt1 to be greater than qt2
> on a intermediate state of the transaction ?
Is this something that could be handled with update and/or insert triggers?
Bruce
Re: Deferrerable Check constraints
От:
"Luiz K. Matsumura" <luiz@planit.com.br>
Дата:
Bruce Hyatt wrote: > Is this something that could be handled with update and/or insert triggers? > I think that no, because there are no way to determine what insert/update is the last of a transaction inside a trigger. -- Luiz K. Matsumura Plan IT Tecnologia Informática Ltda.