case when status not in ('Cancelled', 'Closed', 'Filled' ) then sysdate
when date_filled < date_req_approved then date_last_status_change else coalesce(date_filled, date_last_status_change)
end as date_filled
I think the issue is with sysdate.
ERROR: CLI cursor fetch error: [Oracle][ODBC][Ora]ORA-01840: input value not long enough for date format
Any suggestions how to make this work?
Are you running pass through. This is more of oracle question but one thing is for sure. columns you are comparing or in coalesce do not have same formats
I am running a passthrough. Weirdly my code works just fine in Oracle SQL.
Are you running an explicit sql pass through(via connect statement) or an implicit sql
I am using the connect statement
proc sql;
connect to odbc as ods
if it has worked in oracle sql developer and not working in connect statement. This might be any issue with ODBC connection related issue.
Just Googling the error Oracle throws: It could be that the data types of the columns you're using are not all of type DATE and that some implicit conversion is happening. If such implicit conversion is going on then Oracle will use the format as set in NLS_DATE_FORMAT. If this format doesn't match the string it's trying to convert then you could get the Oracle error you observing.
Following this thought: It's possible that NLS_DATE_FORMAT has a different value depending on how you connect to Oracle (via SAS or SQL Developer).
What I would do:
1. Check if all your data types are DATE
2. If not all columns of type DATE: Cast strings to date using an explicit format using the to_date() function. Don't rely on implicit conversions.
How is columns sysdate populated? Does it have the same attributes as date_filled, date_req_approved, date_last_status_change?
Make sure that all these variable(sysdate, date_last_status_change, date_filled, date_last_status_change) have same date or datetime formats.
If your sysdate is 'DD/MM/YYYY 00:00:00' format and date_last_status_change is 'DD/MM/YYYY' format, then you might get this possible error. Convert them to same format using TO_DATE() in Oracle or convert them all to characters using TO_CHAR.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.