简体   繁体   中英

Error ORA-01858: a non-numeric character was found where a numeric was expected when running query

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

select project_name, my_date, sum(records_number) as 
from (
select project_name, 
  case 
    when :P33_RG = 'Daily' then
      to_char(date_sys, 'MM/DD/YYYY') 
    when :P33_RG = 'Weekly' then
      to_char(TRUNC(date_sys, 'IW'), 'MM/DD/YYYY')
  end as my_date,  
  BATCH.RECORDS_NUMBER
from BATCH
where date_sys between :P33_START_DATE and :P33_END_DATE
) my_records
group by project_name, my_date
;

:P33_START_DATE and:P33_END_DATE are have values of dates from a datepicker and:P33_RG is a varchar.

any advice to fix the error would be appreciated! Thank you

I'd say that you should "convert" date picker values into DATE datatype, using appropriate format model. If it follows what you already posted, that would be

       WHERE date_sys BETWEEN TO_DATE ( :P33_START_DATE, 'mm/dd/yyyy')
                          AND TO_DATE ( :P33_END_DATE  , 'mm/dd/yyyy')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM