oracle 程序 ORA-06550, PLS_00103

Posted

技术标签:

【中文标题】oracle 程序 ORA-06550, PLS_00103【英文标题】:oracle procedure ORA-06550, PLS_00103 【发布时间】:2018-08-27 16:13:01 【问题描述】:

我有一个程序定义为:

 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】:

在您的脚本声明部分:

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 变量,然后将它们传递给您的过程。据推测,您稍后会在脚本中检查这些变量。

【讨论】:

我认为此处文档每行开头的数字会导致错误。 ??? @dandarc 感谢您的快速响应,我按照您的建议更改了销售文件中的调用代码,然后 OYTVAL 变为:OUTVAL=SP2-0552: Bind variable "AS_ERRSTR" not declared. @bob Javis 这些数字不是真实的。当您在vi 编辑器中输入:set nu 时,编辑器将在行首添加数字。 您是否只更改了对过程的调用?请注意,示例中也没有“Declare”语句。 @dandarc 我忘了删除声明。现在这就是我所拥有的:

以上是关于oracle 程序 ORA-06550, PLS_00103的主要内容,如果未能解决你的问题,请参考以下文章

ORA-06550,PLS-00306;向 Oracle 过程插入数据时出错

ORA-06550 和 PLS-00103

pl/sql developer中写SQL时出现ORA-06550和PLS-00553

oracle报错ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'P

ORA-06550:PLS-00306: 调用中的参数数量或类型错误;ORA-06550:

ORA-06550:第 13 行,第 4 列:PLS-00103:遇到“UPDATE” ORA-06550:第 15 行,第 3 列:PLS-00103:遇到符号“END”