I have created a sql query in which I'm passing a parameter to the section shared below
BETWEEN
NVL(TO_CHAR(:DATE1, 'DD-MON-YYYY'), DATETIME)
AND
NVL(TO_CHAR(:DATE2, 'DD-MON-YYYY'), DATETIME)
When I run this query with the data type it works fine but when I run this query with VARCHAR2
parameter it gives the following error:
[Error] Execution (9: 25): ORA-01722: invalid number
When I run this query with null, the query shows up all the records.
actually I need to run this query using a STRING
parameter not with the DATE
dataype so when I pass the parameter to the same query in toad it will work fine even with the null
values.
Here is my complete query:
SELECT rownum,ACCOUNT_NO,CUSTOMER_NAME,CARD_NO, SOURCE, ATM_ID, ISSUER_BANK_NAME,ASE.STATUS_DESC, CARD_TYPE, CARD_RESP,
DATETIME,BR_INPUT_DATE BR_ACTIVITY
FROM ATM_RCCM, ATM_STATUS_ERRORS ASE
where ASE.STATUS_DESC = NVL(:PT, ASE.STATUS_DESC)
AND BR_TRACKING_STATUS = ASE.STATUS_CODE
AND CARD_TYPE = NVL(:CT, CARD_TYPE)
AND DATETIME
BETWEEN
NVL(TO_CHAR(:DATE1, 'DD-MON-YYYY'), DATETIME)
AND
NVL(TO_CHAR(:DATE2, 'DD-MON-YYYY'), DATETIME)
Also note that the DATETIME
column has the default datatype of VARCHAR2
.