简体   繁体   中英

Oracle PL/SQL: What's missing in this trigger?

I'm new to Triggers and PL/SQL in general. FOr testing purpose I'm using slely the Oracle Database Express Edition with its own Command Line.

The script supposed to create a trigger looks like follows:

CREATE OR REPLACE TRIGGER SESSION_LOGIN_HANDLER 
AFTER UPDATE OF LOGGED_IN ON BENUTZERKONTO 
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
DECLARE

BEGIN 

    if (:OLD.LOGGED_IN == 1)
    if (:NEW.LOGGED_IN == 0)
    {
        UPDATE SESSION_LOGGING AS current_session SET DAUER = (sysdate-ZEITSTEMPEL) WHERE DAUER IS NULL AND SECURE_IDENTIFIER = :NEW.SECURE_IDENTIFIER;
    }
END; 

commit;

And I call it with @C:/SQL.../DB_TRIGGER.trg; in the command line. Yet just after calling it, the command line seems just to count the line number with each time I press . It seems like it somehow waits for another line or anything, but I don't know what >< There's also no failure message or anything. I even commented out the entire code between "BEGIN" and "END" with no difference!

Could someone help this beginner? Thanks in advance!

That's no Oracle syntax, it must be like this:

if (:OLD.LOGGED_IN = 1) then
  if (:NEW.LOGGED_IN = 0) then   
     UPDATE SESSION_LOGGING AS current_session SET DAUER = (sysdate-ZEITSTEMPEL) 
     WHERE DAUER IS NULL AND SECURE_IDENTIFIER = :NEW.SECURE_IDENTIFIER;
  end if;
end if;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM