avjoshi
IS-IT--Management
- May 12, 2003
- 221
Hi Guys,
I have a confusing problem,
I wrote following program to populate a table. It gives me an "Invalid Character" error but when I generate output using dbms_output and run it is works as expected.
I get following error
It generates following statements with dbms_output,
And they insert just fine.
Not sure what am I doing wrong.
not sure what am I doing wrong.
Anand
I have a confusing problem,
I wrote following program to populate a table. It gives me an "Invalid Character" error but when I generate output using dbms_output and run it is works as expected.
Code:
Declare
valStr varchar2(250);
tmSlice date;
hh24 number;
mi number;
hago date;
minSeq number;
hrMin varchar2(5);
begin
dbms_output.enable(1000000);
for i in 0..1 loop
tmSlice := trunc(sysdate)+(i/1440);
hh24 := to_number(to_char(tmSlice,'HH24'));
mi := to_number(to_char(tmSlice,'MI'));
hago := tmSlice-(60/1440);
if trunc(tmSlice)-trunc(hago) = 1 then
hago := null;
end if;
minSeq := i+1;
hrMin := to_char(tmSlice,'HH24:MI');
valStr := 'insert into S_ETL_TIME_DAY values (to_date('''||
to_char(tmSlice,'DD-MON-YYYY HH24:MI')||''',''DD-MON-YYYY HH24:MI''),'||
to_char(hh24,'09')||','||
to_char(mi,'09')||',';
if hago is not null then
valStr := valStr ||'to_date('''||
to_char(hago,'DD-MON-YYYY HH24:MI')||''',''DD-MON-YYYY HH24:MI''),';
else
valStr := valStr ||'null,';
end if;
valStr := valStr || minSeq || ',' ||
'''' || hrMin || ''');';
execute immediate valStr;
--dbms_output.put_line(valStr);
end loop;
end;
/
I get following error
Code:
Error at line 2
ORA-00911: invalid character
ORA-06512: at line 33
It generates following statements with dbms_output,
Code:
insert into S_ETL_TIME_DAY values (to_date('27-MAR-2007 00:00','DD-MON-YYYY HH24:MI'), 00, 00,null,1,'00:00');
insert into S_ETL_TIME_DAY values (to_date('27-MAR-2007 00:01','DD-MON-YYYY HH24:MI'), 00, 01,null,2,'00:01');
And they insert just fine.
Not sure what am I doing wrong.
not sure what am I doing wrong.
Anand