在SQLPlus上执行脚本时,它会打印数字序列而不是输出 [英] When executing a script on SQLPlus, it prints a sequence of numbers instead of output
问题描述
我试图在SQL PLus上执行脚本,这很简单.
I'm trying to execute a script on SQL PLus, it's simple.
SET serveroutput ON;
DECLARE
mode NUMBER(1) := 1;
IF (mode = 1) THEN
prompt 'HERE'
END IF;
prompt 'fim'
成功连接后,我使用sqlplus user/pw@db
和@myscript.sql
从SQLPlus调用脚本.但是输出对我来说很奇怪:
I call the script from SQLPlus using sqlplus user/pw@db
and @myscript.sql
after a successful connection. But the output is strange for me:
Conectado a:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> @myscript.sql
9
10
11
并且它将继续无限期地打印此序列. 我在做什么错了?
And it continues to print this sequence indefinitely. What am I doing wrong?
推荐答案
从您已编辑的问题开始……您必须在新行上用/
终止PL/SQL块,以使其结束并运行,否则SQL * Plus将继续提示输入更多行代码(这是您看到的数字). 文档显示了如何运行PL/SQL块.而且prompt
是SQL * Plus命令,因此您不能在PL/SQL块内使用它.您也没有正确的块语法:
From your edited question... you have to terminate the PL/SQL block with a /
on a new line to make it end and run, otherwise SQL*Plus will keep prompting for more lines of code (which is the numbers you're seeing). The documentation shows how to run PL/SQL blocks. And prompt
is a SQL*Plus command so you can't use it inside a PL/SQL block. You also don't have your block syntax right:
SET serveroutput ON;
DECLARE
mode NUMBER(1) := 1;
BEGIN
IF mode = 1 THEN
DBMS_OUTPUT.PUT_LINE('HERE');
END IF;
END;
/
prompt fim
这篇关于在SQLPlus上执行脚本时,它会打印数字序列而不是输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!