如何从SQL命令行获取程序的结果/数据

时间:2016-10-07 09:35:33

标签: sql oracle

查找导致错误消息的原因如下:

[Error] Execution (4: 5): ORA-06550: line 4, column 5: PLS-00306:
wrong number or types of arguments in call to 'ALLOC_DAY_GRAPH_KTL'
ORA-06550: line 4, column 39: PLS-00363: expression '01-Oct-2012'
cannot be used as an assignment target ORA-06550: line 4, column 5:
PLS-00306: wrong number or types of arguments in call to
'ALLOC_DAY_GRAPH_KTL' ORA-06550: line 4, column 5: PL/SQL: Statement
ignored

提前致谢

2 个答案:

答案 0 :(得分:0)

如果这是db中存在的包,则可以编写一个简单的pl sql过程块,该块调用包中的必需过程并将其保存为sql脚本。然后可以使用@ filename.sql

从sqlplus命令行调用它

答案 1 :(得分:0)

这可能是一个简单的方法:

<强>设置:

SQL> CREATE OR REPLACE PACKAGE reports AS
  2      TYPE rep_type IS REF CURSOR;
  3  END reports;
  4  /

Package created.

SQL>
SQL> create or replace procedure testCursor(pIn in number, pCursOut in OUT reports.rep_type) is
  2  begin
  3      open pCursOut for
  4          select 1 as one,
  5                 'something' as text,
  6                 pIn as parameter
  7          from dual;
  8  end;
  9  /

Procedure created.

拨打:

SQL> variable vCur refCursor
SQL> exec testCursor(999, :vCur);

PL/SQL procedure successfully completed.

SQL> print :vCur

       ONE TEXT       PARAMETER
---------- --------- ----------
         1 something        999

SQL>

如果您不在SQLPlus中,则可能需要一个plSQL块:

declare
    vCur reports.rep_type;
begin
    testCursor(999, vCur);
    /* code to use the cursor */
end;
/    

在这种情况下,您需要编写一些代码,以便通过过程返回的光标执行您需要的任何操作。