From: | Jan Wieck <JanWieck(at)Yahoo(dot)com> |
---|---|
To: | Mister ics <mister_ics(at)hotmail(dot)com> |
Cc: | JanWieck(at)Yahoo(dot)com, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: on update restrict |
Date: | 2001-08-15 14:02:11 |
Message-ID: | 200108151402.f7FE2BW01192@jupiter.us.greatbridge.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Mister ics wrote:
> >
> > The behaviour is correct according to the SQL specifications.
> > RESTRICT (as well as NO ACTION) means, you cannot change the
> > primary key value of the referenced row. All other values can
> > be changed of course.
> >
> > So an attempt to
> >
> > UPDATE t1 SET id = 2 WHERE id = 1;
> >
> > is the thing prevented in your above example.
> >
> >
> >Jan
> >
>
>
> Hi Jan,
>
> Thank you , i understand now.
>
> Do you know a method to block the update of certain rows in a table not
> using the triggers ? I explain better:
> I have the needing to prevent the updating of a set of rows in a table. The
> first solution i can find is to use a boolean column (es. "Blocked") and
> rising a trigger on updating the table. The trigger checks if the row is
> updatable or not (checking the "Blocked" column).
> Is this the only (or better) way to do this ?
Since you only want to suppress the operation in that case,
it could be done with a rule too. But I think the cleaner
solution is with a BEFORE trigger raising an ERROR or
returning NULL to suppress the operation.
And consider that you might want to be able to unblock the
row's again. In that case, the trigger is the only way I
see, because you need the procedural logic to check the
blocked true->false transition and let THAT change happen.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Barrett | 2001-08-15 15:08:42 | \set variant for use in regular sql commands |
Previous Message | Alan Gutierrez | 2001-08-15 13:49:35 | Re: Re: DateDiff, IsNull? |