0
create or replace TRIGGER SET_HOLDER_IN_ONLINE_DOC
BEFORE  INSERT ON tasks 
FOR EACH ROW
DECLARE 
id, repl_id NUMBER;
BEGIN
  IF :new.holder_role_id = 10 THEN
    SELECT user_id, repl_user_id  INTO id, repl_id  FROM roles 
      WHERE roles.id=10;
      IF repl_id = 0 THEN
        :new.holder_user_id := id;
      ELSE
          WHILE repl_id > 0
          LOOP
              SELECT user_id, repl_user_id  INTO id, repl_id  FROM roles 
                 WHERE user_id=repl_id;
          END LOOP;
          :new.holder_user_id := id;
      END IF;
  END IF;
END;
4

1 回答 1

2

您不能像在其他一些语言中那样声明两个变量,所以:

DECLARE 
id, repl_id NUMBER;
BEGIN

应该:

DECLARE 
id NUMBER:
repl_id NUMBER;
BEGIN
于 2013-07-18T15:36:52.023 回答