oracle程序ORA-06550,PLS_00103

时间:2018-08-27 16:13:02

标签: oracle shell ora-06550 pls-00103

我的程序定义为:

 PROCEDURE Import_Invoice 
  (     as_Directory_Name_Invoice_Data in varchar2,
        as_File_Name_Invoice_Data in varchar2,
        as_Directory_Name_Invoice_Log in varchar2,
        al_processid out number, 
        al_errnum out number,
        as_errstr out varchar2 ) IS

 begin
           al_processid := 123;
           al_errnum := 2;
           as_errstr := 'sfs';
end;

当我从shell脚本执行以下过程时:

#! /bin/ksh
::::::::::::
OUTVAL=`sqlplus -s usr/passwd@ora_instance <<EOF
264 whenever sqlerror exit failure rollback
265 set pagesize 0
266 set feed off
267 set echo off
268 set serveroutput on
269 DECLARE
270 var al_errnum number,
271 var as_errstr varchar2,
272 var al_processid number,
273 BEGIN
274 execute Import_Invoice('INVOICE_INBOUND_DAT_DIR','INVOICE_apvend_daily.dat','INVOICE_INBOUND_LOG_DIR', al_processid, al_errnum, as_errstr );
275 END
276 /
277 EOF`

::::::

OUTVAL返回为:

OUTVAL=var al_errnum number, CAMS_INVOICE_20180802_120830.DAT INVOICE_apvend_daily.dat ERROR at line 2: ORA-06550: line 2, column 15: PLS-00103: Encountered the symbol "NUMBER" when expecting one of the following: := . ( @ % ; not null range default character

我找不到问题所在。

感谢您的建议。

更新按照@dandarc的建议,我将调用代码更改为:

OUTVAL=`sqlplus -s usr/passwd@ora_instance <<EOF
whenever sqlerror exit failure rollback
set pagesize 0
set feed off
set echo off
set serveroutput on
var al_errnum number
var as_errstr varchar2(1000)
var al_processid number
BEGIN
execute Import_Invoice('INVOICE_INBOUND_DAT_DIR','INVOICE_apvend_daily.dat','INVOICE_INBOUND_LOG_DIR', :al_processid, :al_errnum, :as_errstr );
END
/
EOF`

我收到此错误:

OUTVAL=execute Import_Invoice('INVOICE_INBOUND_DAT_DIR','INVOICE_apvend_daily.dat','INVOICE_INBOUND_LOG_DIR', :al_processid, :al_errnum, :as_errstr ); CAMS_INVOICE_20180802_120830.DAT INVOICE_apvend_daily.dat ERROR at line 2: ORA-06550: line 2, column 9: PLS-00103: Encountered the symbol "IMPORT_INVOICE" when expecting one of the following: := . ( @ % ; immediate The symbol ":=" was substituted for "IMPORT_INVOICE" to continue. ORA-06550: line 3, column 3: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ; <an identifier> <a double-quoted delimited-identifier> The symbol ";" was substituted for "end-of-file" to continue.

请帮助。

1 个答案:

答案 0 :(得分:1)

在脚本声明部分:

269 DECLARE
270 var al_errnum number,
271 var as_errstr varchar2,
272 var al_processid number,

应该是:

269 DECLARE
270  al_errnum number;
271  as_errstr varchar2;
272  al_processid number;

PL / SQL不需要var,并且每一行都应以分号结尾。

这将清除错误,但是您可能想要一个看起来像这样的脚本:

#! /bin/ksh
::::::::::::
OUTVAL=`sqlplus -s usr/passwd@ora_instance <<EOF
whenever sqlerror exit failure rollback
set pagesize 0
set feed off
set echo off
set serveroutput on
var al_errnum number
var as_errstr varchar2(20)
var al_processid number
BEGIN
Import_Invoice('INVOICE_INBOUND_DAT_DIR','INVOICE_apvend_daily.dat','INVOICE_INBOUND_LOG_DIR', :al_processid, :al_errnum, :as_errstr );
275 END
276 /
277 EOF`

::::::

声明sqlplus变量,然后将其传递给过程。据推测,您稍后将在脚本中检查这些变量。