I am trying to create a dynamic sql process based upon the following update code:
UPDATE WORKORDER
SET STATUS = 'COMP'
WHERE REPORTDATE >= TO_DATE('08/01/2006','mm/dd/yyyy')
AND STATUS = 'INPRG'
AND ACTFINISH IS NOT NULL
AND WONUM NOT LIKE '7%'
Which works fine. The dynamic sql code is as follows:
declare
WTABLE varchar2(64) := 'WORKORDER';
WCOL varchar2(64) := 'STATUS';
IVALUE varchar2(64) := 'INPRG';
CVALUE varchar2(64) := 'COMP';
ADATE DATE := 'to_date(ACTFINISH)';
dyn_sql varchar2(64);
WONUM varchar2(64) := '7%';
begin
dyn_sql := 'update '||WTABLE||' set '||WCOL||' = '''||IVALUE|| ''' WHERE '||ADATE||' IS NULL
AND '||WCOL||' = '''||CVALUE|| '''';
dbms_output.put_line(dyn_sql);
execute immediate dyn_sql;
end;
/
When I run in sql I get the following error:
ADATE DATE := 'to_date(ACTFINISH)';
*
ERROR at line 6:
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at line 6
I have tried to reformat the date field and nothing works. Can anyone offer any suggestions?
Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.
UPDATE WORKORDER
SET STATUS = 'COMP'
WHERE REPORTDATE >= TO_DATE('08/01/2006','mm/dd/yyyy')
AND STATUS = 'INPRG'
AND ACTFINISH IS NOT NULL
AND WONUM NOT LIKE '7%'
Which works fine. The dynamic sql code is as follows:
declare
WTABLE varchar2(64) := 'WORKORDER';
WCOL varchar2(64) := 'STATUS';
IVALUE varchar2(64) := 'INPRG';
CVALUE varchar2(64) := 'COMP';
ADATE DATE := 'to_date(ACTFINISH)';
dyn_sql varchar2(64);
WONUM varchar2(64) := '7%';
begin
dyn_sql := 'update '||WTABLE||' set '||WCOL||' = '''||IVALUE|| ''' WHERE '||ADATE||' IS NULL
AND '||WCOL||' = '''||CVALUE|| '''';
dbms_output.put_line(dyn_sql);
execute immediate dyn_sql;
end;
/
When I run in sql I get the following error:
ADATE DATE := 'to_date(ACTFINISH)';
*
ERROR at line 6:
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at line 6
I have tried to reformat the date field and nothing works. Can anyone offer any suggestions?
Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.