【问题标题】:oracle pl/sql input errororacle pl/sql 输入错误
【发布时间】:2016-05-28 14:23:44
【问题描述】:

代码:

DECLARE
 N NUMBER :=&N;
BEGIN
 DBMS_OUTPUT.PUT_LINE(N);
END;

错误:

ORA-06550:第 2 行,第 12 列:PLS-00103:遇到符号“&” 预期以下情况之一时:

( - + case mod new not null continue avg count current 存在 max min prior sql stddev sum variance 执行 forall 合并 时间 时间戳 间隔 日期 管道

【问题讨论】:

  • 我可以知道您正在使用的 IDE 吗?
  • oracle 10g sql 命令
  • 你是否尝试过设置定义;

标签: oracle plsql oracle10g


【解决方案1】:

你需要做的:

SET DEFINE ON

我认为您正在使用 SQL Developer 之类的 GUI 客户端,并且您没有定义。 & 用于替换变量

SQL 开发人员中:

SET serveroutput ON
SET define OFF
DECLARE
  N NUMBER :=&N;
BEGIN
  DBMS_OUTPUT.PUT_LINE(N);
END;
/

Error starting at line : 8 in command -
DECLARE
  N NUMBER :=&N;
BEGIN
  DBMS_OUTPUT.PUT_LINE(N);
END;
Error report -
ORA-06550: line 2, column 14:
PLS-00103: Encountered the symbol "&" when expecting one of the following:

   ( - + case mod new not null <an identifier>
   <a double-quoted delimited-identifier> <a bind variable>
   continue avg count current exists max min prior sql stddev
   sum variance execute forall merge time timestamp interval
   date <a string literal with character set specification>
   <a number> <a single-quoted SQL string> pipe
   <an alternatively-quoted string literal with character set specification>
   <an alternatively
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

开启定义,然后重试:

SQL> SET serveroutput ON
SQL> SET DEFINE ON
SQL> DECLARE
  2    N NUMBER :=&N;
  3  BEGIN
  4    DBMS_OUTPUT.PUT_LINE(N);
  5  END;
  6  /
Enter value for n: 10
old   2:   N NUMBER :=&N;
new   2:   N NUMBER :=10;
10

PL/SQL procedure successfully completed.

SQL>

【讨论】:

  • 它在 SQL 开发人员中成功运行,但在 oracle 10g“sql 命令”中无法运行。它说缺少或无效的选项。
  • 我无法正确定义它,但它运行在 10g express edition 及其“SQL commands”命名的浏览器中执行 sql 查询。
  • 你必须说出你在做什么。您使用的是哪个客户端?至少,告诉我们您是否了解客户?
  • oracle 10g express edition,我在浏览器(firefox、chrome等)中打开的sql命令中编写命令。
猜你喜欢
  • 1970-01-01
  • 2012-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多