I have a query.
i have a config table AB where a row is marked as "sysdate-360"
col1 ||col2
AB || sysdate-360
BC || sysdate -2
When i write a procedure to get date value from the config table AB i used.
v_date varchar(20);
cursor c1 as
select col2 from AB;
then
for ab_date in c1
loop
select ab_date.col2 into v_date from dual;
v_sql := 'delete from any_table where load_date <='||v_date;
execute immediate v_sql ;
commit;
end loop;
The procedure is compiled but when i execute I'm getting below error
ORA-01722: invalid number
ORA-06512: at "procedure", line 46
ORA-06512: at line 1
01722. 00000 - "invalid number"
*Cause:
*Action:
The sysdate -360 is considered as char but not as date since SYSDATE is itself a date right?
Please help.
load_date
is a date type. Your obfuscation is confusing things a bit as your cursor query doesn't look right - is it reallyfrom config_table where col1 = AB
? and you haven't indicated which line corresponds to line 46 in the error. What data type iscol1
, as you've made it look like a varchar? If it is a string, isAB
a number, and you aren't enclosing it in quotes, and there arecol1
values that are not numbers? I think the error is from the cursor query, and nothing to do with the date.... - Alex Poolev_sql
that you pass toexecute immediate
. This will likely reveal your problem, such as a missing space inv_sql
. - WW.