sql - ORA-01839 "date not valid for month specified" for to_date in where clause -
i have following query (bocrtntime - varchar e.g 2015-02-28 12:21:45, view_base_marix_t - view):
select bocrtntime view_base_marix_t to_date(substr(bocrtntime,1,10),'yyyy-mm-dd') between (to_date ('2016-01-01', 'yyyy-mm-dd')) , (to_date ('2016-02-01', 'yyyy-mm-dd')) on executing error:
ora-01839: "date not valid month specified" i thought there can incorrect data in bocrtntime, execute following query:
select distinct substr(bocrtntime,1,8), substr(bocrtntime,9,2) view_base_marix_t order substr(bocrtntime,9,2); but looks fine: http://pastebin.com/fnjp4uau. following query executes without error:
select to_date(substr(bocrtntime,1,10),'yyyy-mm-dd') view_base_marix_t; i tried add trunc() to_date() no luck. create pl/sql procedure takes 1 one item form view_base_marix_t , convert date - , works fine. ideas why error on first query?
upd: query on table used in view works fine, in view - not
upd2: have few enviroments same products, error on one
upd3: issue resolved search non valid dates in table used in view
i think might happening oracle pushing predicate underlying tables of view.
have tried run query
select to_date(substr(bocrtntime,1,10),'yyyy-mm-dd') bocrtntime my_table instead of querying view?
you can confirm using no_push_pred hint
select /*+ no_push_pred(view_base_marix_t) */ bocrtntime view_base_marix_t to_date(substr(bocrtntime,1,10),'yyyy-mm-dd') between (to_date ('2016-01-01', 'yyyy-mm-dd')) , (to_date ('2016-02-01', 'yyyy-mm-dd'))
Comments
Post a Comment