0

I have created a procedure to find a date between today and expiry_date. The table column format is already in date format.

While creating procedure it is created successfully without errors but during execution of procedure as below it is showing

ORA-01858: a non-numeric character was found where a numeric was expected

ALTER SESSION SET NLS_DATE_FORMAT ='dd-mm-yyyy';
CREATE OR REPLACE PROCEDURE flow (
    today  IN                  DATE,
    expiry_date       IN       DATE
) AS

BEGIN
    FOR  rec in (
        SELECT *
        FROM flow4
        WHERE englishcalendar BETWEEN 'englishcalendar.today' 
                    AND 'englishcalendar.expiry_date')
    LOOP
        dbms_output.put_line(rec.englishcalendar);
    END LOOP;

EXCEPTION
    WHEN OTHERS THEN
        dbms_output.put_line(sqlerrm);
END;
/

EXEC FLOW('01-02-2017','03-04-2018');
/

I had also tried adding to_date in both procedure and procedure execution but i got same error I also tried with this reference too Getting Error - ORA-01858: a non-numeric character was found where a numeric was expected

NOTE englishcalendar contains continuous day of 2019 in 'dd-mm-yyyy' date format

APC
  • 144,005
  • 19
  • 170
  • 281
Suman
  • 160
  • 1
  • 9
  • `WHERE englishcalendar BETWEEN 'englishcalendar.today' AND 'englishcalendar.expiry_date')` seems incorrect. Please share the schema of table flow4. – Ankit Bajpai May 21 '19 at 17:30
  • hr.flow4.englishcalendar.today (Schema ==> HR , flow4 ==> Table_name, englishcalendar ==> Column name and today ==> procedure INPARAM) @AnkitBajpai – Suman May 21 '19 at 17:34
  • I meant table flow4's structure. – Ankit Bajpai May 21 '19 at 17:37

1 Answers1

1

'englishcalendar.today' is a string not a date. Likewise 'englishcalendar.expiry_date'. Oracle is attempting to convert these strings to dates and failing, because they are not dates.

Simple solution: reference the parameters as identifiers not strings:

 ... 
  FOR  rec in (
    SELECT *
    FROM flow4
    WHERE englishcalendar BETWEEN today
                AND expiry_date)
...
APC
  • 144,005
  • 19
  • 170
  • 281
  • Thank you @APC a lot you have done great work through which i am struggling for hours !! – Suman May 21 '19 at 17:54