这是我编写的脚本,它在 EXCEPTION 块中有奇怪的语法错误。如果我删除异常块,脚本会正确编译。但是我一写回它就给我错误
Error(58,11): PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following: ( begin case declare else elsif end exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
这是脚本
LOOP
BEGIN
SAVEPOINT check_point;
EXIT WHEN DBMS_SQL.FETCH_ROWS (cursor_handle) = 0;
DBMS_SQL.COLUMN_VALUE (cursor_handle, 1, cc , col_err, actual_len);
DBMS_SQL.COLUMN_VALUE (cursor_handle, 2, di, col_err, actual_len);
IF INSTR (cc, '_') <> 0 THEN
cc := Trim (cc);
cc := Upper(cc);
cc := substr(cc,4,2);
EXECUTE IMMEDIATE 'UPDATE ' || dest || ' SET cc = :v1 WHERE di = :v2'
USING cc, di;
if SQL%ROWCOUNT > 0 THEN
inserts := inserts + 1;
counter := counter + 1;
IF counter > 500 THEN
counter := 0;
COMMIT;
END IF;
END IF;
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
dups := dups+1;
ROLLBACK TO check_point;
WHEN VALUE_ERROR THEN
valerr := valerr +1;
ROLLBACK TO check_point;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('errno: ' || TO_CHAR(SQLCODE) || ' Msg: ' || SQLERRM);
otherexc := otherexc +1;
IF otherexc > 50 THEN
EXIT;
END IF;
ROLLBACK TO check_point;
END IF;
END;
END LOOP;
我知道问这样的问题很烦人,但我无法弄清楚那是什么错误。我是 Pl/SQL 的雷曼兄弟。