Emulation contrainte check avec fonction
Bonjour,
Voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| SET SERVEROUTPUT ON
/
create table RANDRIANO.DRIA_TEST (
"ID" varchar2(38),
"CONTENT" varchar2(38) NOT NULL,
"MYVALUE" INT,
"SYSTEM" NUMBER (38) DEFAULT 0,
CONSTRAINT "PK_DRIA_TEST" PRIMARY KEY(ID)
USING INDEX TABLESPACE RANDRIANOINDEX
) TABLESPACE RANDRIANODATA
LOGGING
/
CREATE OR REPLACE TRIGGER RANDRIANO.B_I_DRIA_TEST
before
INSERT ON RANDRIANO.DRIA_TEST
FOR EACH ROW
DECLARE
v_value int;
BEGIN
v_value := :new.MYVALUE;
dbms_output.put_line('ligneAvant.MYVALUE = ' || v_value);
if (v_value <> 0 or v_value <>1) then
raise_application_error(-20000,'Check_DRIA_TEST');
end if ;
END ; |
J'émule donc la contrainte CHECK avec un trigger: ici, on a un simple CHECK sans fonction (MYVALUE <> 0 or MYVALUE <>1)
Je teste la requête:
Code:
insert into RANDRIANO.DRIA_TEST values('KUAKO','lalala',0,5)
Ici, j'ai MYVALUE = 1 respectant la contrainte, le dbms_output.put_line l'affiche même mais j'ai toujours
ERROR at line 1:
ORA-20000: Check_DRIA_TEST
ORA-06512: at "RANDRIANO.B_I_DRIA_TEST", line 11
ORA-04088: error during execution of trigger 'RANDRIANO.B_I_DRIA_TEST'