2017-10-10 45 views
-2

这是我的代码,PL/SQL对于与当错误

Declare 
For num IN 1..10 LOOP 
Continue When Mod(num,2)!=0; 
DBMS_OUTPUT.PUT_LINE(num); 
END LOOP; 
END; 
/

我收到以下错误:

SQL> @ E:\dbms\f7.sql 
For num IN 1..10 LOOP 
* 
ERROR at line 2: 
ORA-06550: line 2, column 1: 
PLS-00103: Encountered the symbol "FOR" when expecting one of the following: 
begin function package pragma procedure subtype type use 
<an identifier> <a double-quoted delimited-identifier> form 
current cursor 
The symbol "begin" was substituted for "FOR" to continue. 
ORA-06550: line 3, column 10: 
PLS-00103: Encountered the symbol "WHEN" when expecting one of the following: 
:= . (@ % ; 

请人给我一个工作代码,所以我可以执行!

+1

'begin'缺少 –

+0

我也不过还是开始尝试错误正在显示! 您能否以适当的格式编写代码? –

+0

代码应该做什么?你显示一些带有语法错误的代码,因此不会做你需要它做的事情。我们是否有某种超自然的存在,你认为我们可以猜出你需要做什么,从一个无效的尝试,没有其他解释?无论如何,你认为“继续”会有什么作用?在你的代码中,你认为'when'意味着什么?你是不是指“如果”? – mathguy

回答

0

因为你没有任何声明的变量您不需要declare块,但是你错过了begin关键字:

BEGIN -- Here 
    FOR num IN 1..10 LOOP 
     Continue When Mod(num,2)!=0; 
     DBMS_OUTPUT.PUT_LINE(num); 
    END LOOP; 
END; 
/
+0

执行上面的代码之后,现在它向我显示此错误 SQL> @ E:\ dbms \ f7.sql继续当Mod(num,2)!= 0; *第3行的错误:ORA-06550:第3行,第18列:PLS-00103:遇到下列其中一项时遇到符号“WHEN”::=。 (@%; - –