oracle PLS-00103:在检查绑定变量中的值时遇到符号“EXCEPTION”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8458716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PLS-00103: Encountered the symbol "EXCEPTION" error while checking for a value in the bind variable
提问by ajay rk
I am getting the below error for the PL/SQL block I executed.
我执行的 PL/SQL 块出现以下错误。
ORA-06550: line 16, column 1: PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
ORA-06550:第 16 行,第 1 列:PLS-00103:在预期以下情况之一时遇到符号“EXCEPTION”:
My anonymous procedure below was working fine until I included the user defined exception e_nonrented
. Which checks if the value of bindvariable :g_movie_id=2..
If that is the case it throws an exception...
我下面的匿名程序运行良好,直到我将user defined exception e_nonrented
. 它检查如果bindvariable :g_movie_id=2..
是这种情况的值,它会抛出异常......
Below is the code:
下面是代码:
VARIABLE g_movie_id NUMBER EXEC :g_movie_id := 2
DECLARE v_count NUMBER;
v_movieid NUMBER;
v_title mm_movie.movie_title%TYPE;
e_nonrented
EXCEPTION;
BEGIN
SELECT m.movie_title,
COUNT(r.rental_id),
r.movie_id
INTO v_title,
v_count,
v_movieid
FROM mm_movie m,
mm_rental r
WHERE m.movie_id = r.movie_id
AND m.movie_id = :g_movie_id
GROUP BY m.movie_title,
r.movie_id;
DBMS_OUTPUT.PUT_LINE(v_title || ': ' || v_count);
IF :g_movie_id = 2 THEN
RAISE e_nonrented;
EXCEPTION
WHEN no_data_found THEN
DBMS_OUTPUT.PUT_LINE('there is no movie id for: ' || :g_movie_id);
WHEN e_nonrented THEN
DBMS_OUTPUT.PUT_LINE(' Movie with Id ');
END;
回答by Mat
You're simply missing an END IF;
statement.
你只是缺少一个END IF;
声明。
IF :g_movie_id = 2 THEN
RAISE e_nonrented;
END IF;
EXCEPTION