我正在运行最基本的oracle sql脚本,并在sqlplus中运行它。
我不明白为什么我的脚本停止提示我输入“为行输入值”。FOR循环不应该在循环之前打开光标吗?
代码为:
SET SERVEROUTPUT ON SIZE UNLIMITED
SET LINESIZE 140
SET PAGESIZE 60
SET ECHO OFF
SET TERM ON
SET FEEDBACK OFF
SET SHOW ON
SET VERIFY OFF
SPOOL &1
DECLARE
text_line VARCHAR2(4000);
CURSOR myCursor IS
select spriden_pidm, spriden_id, spriden_first_name, spriden_last_name from spriden where spriden_id = '1234';
myCursorRec myCursor%ROWTYPE;
BEGIN
FOR myCursorRec IN myCursor LOOP
text_line := text_line + myCursorRec.spriden_last_name;
END LOOP;
DBMS_OUTPUT.PUT_LINE('This is the output: ' || text_line || ', ');
END;
/
SPOOL OFF
EXIT
我用这个命令运行它:
sqlplus dbuser/userpass@dbserver @myTest MYSPOOL
输出如下所示:
SQL*Plus: Release 11.1.0.7.0 - Production on Wed Feb 7 13:06:51 2018
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
new: showmode BOTH
old: verify ON
new: verify OFF
Enter value for row: gggggg
DECLARE
*
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 14
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
为什么我会得到“为行输入值:”提示???