SQLPLUS 正在让我的脚本提示:Enter value for row
SQLPLUS is making my script to prompt: Enter value for row
我运行正在使用最基本的 oracle sql 脚本,运行正在 sqlplus 中使用它。
我不明白为什么我的脚本停止提示我输入 'Enter value for row'。 FOR 循环不是应该在循环之前打开游标吗?
密码是:
/*
File: myTest.sql
*/
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
/* Run Parameters & Variables */
DECLARE
text_line VARCHAR2(4000);
/* Cursors & Row Types */
CURSOR myCursor IS
select spriden_pidm, spriden_id, spriden_first_name, spriden_last_name from spriden where spriden_id = '1234';
myCursorRec myCursor%ROWTYPE;
/* Main Logic */
BEGIN
/* Read through all the entries form our data sources. */
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 is needed for Windows environments. */
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
为什么我会收到 'Enter value for row:' 提示???
因为和号,这里:
/* Cursors & Row Types */
将 SET DEFINE OFF
包含到您的 SET 命令集中,然后重试。
或者,或者,使用 AND :)
/* Cursors and Row Types */
我运行正在使用最基本的 oracle sql 脚本,运行正在 sqlplus 中使用它。 我不明白为什么我的脚本停止提示我输入 'Enter value for row'。 FOR 循环不是应该在循环之前打开游标吗?
密码是:
/*
File: myTest.sql
*/
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
/* Run Parameters & Variables */
DECLARE
text_line VARCHAR2(4000);
/* Cursors & Row Types */
CURSOR myCursor IS
select spriden_pidm, spriden_id, spriden_first_name, spriden_last_name from spriden where spriden_id = '1234';
myCursorRec myCursor%ROWTYPE;
/* Main Logic */
BEGIN
/* Read through all the entries form our data sources. */
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 is needed for Windows environments. */
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
为什么我会收到 'Enter value for row:' 提示???
因为和号,这里:
/* Cursors & Row Types */
将 SET DEFINE OFF
包含到您的 SET 命令集中,然后重试。
或者,或者,使用 AND :)
/* Cursors and Row Types */