0

I have a shell script that calls an Oracle Stored Procedure. The SP has two parameters - the first is of type VARCHAR2 and the second is of type DATE

CREATE OR REPLACE PROCEDURE MY_SCHEMA.MY_SP_NAME(firstParameter IN VARCHAR2, dateParameter IN DATE)
IS

BEGIN

    DBMS_OUTPUT.PUT_LINE('Successfully called Procedure');

END;
/

In my shell script, I'm trying to execute the procedure using the following command:

echo "EXECUTE MY_SCHEMA.MY_SP_NAME('TEST', '20170909') " | $ORACLE_HOME/bin/sqlplus $ORAUSER/$ORAPASS   

The problem is that when the script runs I get the following error: ORA-01861: literal does not match format string. My guess is that there is an issue with the '20170809' value that I'm passing to the date parameter but I'm unsure how to resolve this. Any help is appreciated.

(PS: The ORACLE_HOME/USER/PASS environment variables are all set correctly and I can successfully run SQLPLUS from the script so there are no problems connecting to the Oracle database)

1
  • Please try ... ('TEST', date '2017-09-09'). It is universal syntax for dates, not depending on local settings. Commented Nov 9, 2017 at 11:41

1 Answer 1

1

You can try to use the to_date function:

Execute my_schema.my_sp_name(‘test’,to_date(‘20170909’, ‘yyyymmdd’))

Or use ISO date format in your date parameter.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.