PLS-00103: Encountered the symbol “;” when expecting one of the following:

时间:2015-06-15 14:16:49

标签: plsql plsqldeveloper

What is wrong with my PLSQL?

I get this error message:

ORA-06550: line 4, column 0:PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:* & = - + ; < / > at in is mod remainder not rem <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset

|

<<outer_block>>
DECLARE
mgr_id NUMBER(6) :='&current_manager_id';
dept_count number := 0;
BEGIN
SELECT count(*) INTO dept_count FROM EMP WHERE EMPNO = outer_block.mgr_id;
IF dept_count > 0 THEN
    << inner_block >>
    DECLARE
        dept_name VARCHAR2(30);
        mgr_id NUMBER(6) := &new_manager_id;
    BEGIN
        SELECT EMPNO INTO dept_name FROM EMP WHERE manager_id = outer_block.mgr_id; 
        UPDATE EMP SET MGR = inner_block.mgr_id WHERE MGR = outer_block.mgr_id;
        DBMS_OUTPUT.PUT_LINE('Department manager ID has been changed for ' || dept_name);
    END inner_block;
ELSE
    DBMS_OUTPUT.PUT_LINE('There are no departments listed for the manager');
END IF;
EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('There are no departments listed for the manager');
END outer_block;
/

1 个答案:

答案 0 :(得分:0)

不需要(也无效)在代码之外添加块标签。尝试类似:

DECLARE
  o_mgr_id NUMBER(6) := 1;
  dept_count number := 0;
BEGIN
  SELECT count(*) 
  INTO dept_count 
  FROM EMP 
  WHERE EMPNO = o_mgr_id;

  IF dept_count > 0 THEN
    <<inner_block>>
    DECLARE
        dept_name VARCHAR2(30);
        i_mgr_id NUMBER(6) := 1;
    BEGIN
        SELECT EMPNO INTO dept_name FROM EMP WHERE mgr = o_mgr_id; 
        UPDATE EMP SET MGR = i_mgr_id WHERE MGR = o_mgr_id;
        DBMS_OUTPUT.PUT_LINE('Department manager ID has been changed for ' || dept_name);
    END inner_block;
  ELSE
    DBMS_OUTPUT.PUT_LINE('There are no departments listed for the manager');
  END IF;
EXCEPTION
    WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('There are no departments listed for the manager');
END outer_block;
/
相关问题