Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Trigger issue
For example trigger like this (see when clause)
create or replace trigger trigger_name
BEFORE INSERT OR UPDATE ON a table
REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
when (
(new.col1 is null or new.col2 is null or new.col3 is null)
and
(new.col1 is not null or new.col2 is not null or new.col3 is not null)
)
begin
and raise_application_error (-20001, 'All columns must have values or
must be null');
end;
/
Rafal Czekala (czekala_at_real.pl)
In article
<A5EA56F0ED16AECD.53EDBFFF32AA10E6.297DB169E3B81556_at_lp.airnews.net>,
"wozi" <wozi_at_dhc.net> wrote:
> I want some suggestion on creating a trigger for a
> BEFORE INSERT OR UPDATE ON a table
>
> My table has 3 columns:
> col1 col2 col3
>
> Here is the business rule I am trying to enforce during insert or
update:
> 1. If all 3 columns are null, that's ok. No need for trigger.
> 2. If all 3 columns are NOT null, that's ok. No no need for trigger.
> 3. If one column is NOT null, then all 3 columns must be NOT null,
then
> trigger
> must not permit insert or update.
>
> When replying, please copy tyc77_at_hotmail.com
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Tue Aug 10 1999 - 04:10:26 CDT