Trigger doesn't working in oracle sql -
I have a table called reading
, there is a column call ReaderID
To specify who is read to read, now I want to add a trigger when adding a new row to the reading
, always check if the reader has already read 5 times Yes, then do not mix, to ensure that a reader can not read more than 5 times here is my code, That which is not working, the row can still be inserted without checking
Before creating or inserting the TRIGGER TRIGGER1 REPLACE, read each row declaration for the varReaderCount int. VarRID Int; BEGIN varRID: =: new.ReaderID; Select varReaderCount by reading COUNT (*) Where ReaderID = varRID; IF (varReaderCount> = 5) Then start DBMS_OUTPUT.PUT_LINE ('************************************************************************************************* *** ***************************); DBMS_OUTPUT.PUT_LINE ('Reader has reached the reading limit.'); DBMS_OUTPUT.PUT_LINE ('********************************************************************** ** ***** '); Return; End; end if; End;
I do not know why.
By completing INSERT
, you will get an exception to your trigger in the Raises
and by the way, those DBMS_OUTPUT.PUT_LINE ()
calls do not make any sense -. Trigger runs deep into the intestine of Oracle and there is nowhere to display that output
Comments
Post a Comment