代码之家  ›  专栏  ›  技术社区  ›  Salvador Valencia

SQLPLUS正在使我的脚本提示:为行输入值

  •  0
  • Salvador Valencia  · 技术社区  · 7 年前

    我正在运行最基本的oracle sql脚本,并在sqlplus中运行它。 我不明白为什么我的脚本停止提示我输入“为行输入值”。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
    

    为什么我会得到“为行输入值:”提示???

    1 回复  |  直到 7 年前
        1
  •  7
  •   Littlefoot    7 年前

    由于使用了符号,此处:

    /* Cursors & Row Types */
    

    包括 SET DEFINE OFF 输入set命令集,然后重试。

    或者,使用和:)

    /* Cursors and Row Types */