我需要运行一个查询,我需要使用一个常量(这样我们就可以更改其值并直接影响查询中使用的值)。
declare
QTY_TRESHOLD CONSTANT NUMBER(10,0) := 1;
begin
select * from FD111200_DBF where M_NB = QTY_TRESHOLD
end;
如果我尝试运行上述操作,我会在第一个语句中收到以下错误:
An error occurred when executing the SQL command:
declare
QTY_TRESHOLD CONSTANT NUMBER(10,0) := 1
ORA-06550: line 2, column 39:
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 [SQL State=65000, DB Errorcode=6550]
Execution time: 0.01s
1 statement(s) failed.
我做错了什么?看一下Oracle的the sample,看起来这应该是很好的语法。 谁能帮我理解?
答案 0 :(得分:1)
更多评论而非答案,但评论时间过长;
我刚刚尝试添加INTO
和;
:
SQL> CREATE TABLE FD111200_DBF(M_NB NUMBER);
Table created.
SQL> insert into FD111200_DBF values (1);
1 row created.
SQL> declare
2 QTY_TRESHOLD CONSTANT NUMBER(10,0) := 1;
3 var number;
4 begin
5 select M_NB
6 into var
7 from FD111200_DBF where M_NB = QTY_TRESHOLD;
8 --
9 dbms_output.put_line(var);
10 end;
11 /
1
PL/SQL procedure successfully completed.