I have a procedure defined as:
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;
when I execute the procedure from a shell script as:
#! /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 returned as:
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
I can't find what is wrong.
Thanks you for your suggestions.
Update: as @dandarc suggested, I change the calling code to:
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`
I get this error:
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.
Please help.
In your script declaration section:
Should be:
PL/SQL doesn't need var, and each line should end with a semi-colon there.
That would clear the error, but you probably want a script that looks something like this:
Declare sqlplus variables, then pass those to your procedure. Presumably, you'd check those variables later in your script.