inserting a date [message #370649] |
Fri, 14 January 2000 15:52 |
Kelsi
Messages: 2 Registered: January 2000
|
Junior Member |
|
|
I'm having trouble with inserting dates. I'm get an error message saying that ORA-01858: a non-numeric character was found where a numeric was expected ORA-06512:
Please help.
The code follows:
FOR i in 1..45 LOOP
select sysdate - 45 + i into v_report_date from dual;
For v_getlclsrv_rec in c_getlclsrv LOOP
insert into fault.local_dpms values (v_getlclsrv_rec.ac, '0','0', '0', TO_DATE(v_report_date,'mm/dd/yyyy hh:mi:ss AM'));
END LOOP;
END LOOP;
|
|
|
Re: inserting a date [message #370650 is a reply to message #370649] |
Fri, 14 January 2000 20:15 |
Paul
Messages: 164 Registered: April 1999
|
Senior Member |
|
|
Kelsi,
Apparently v_report_date is defined as a date, and the column you are inserting it into is also a date datatype, you do not need to TO_CHAR it in your INSERT, that is what is causing the problem.
Hope this helps,
Paul
|
|
|
Re: inserting a date [message #370747 is a reply to message #370649] |
Fri, 28 January 2000 17:51 |
Edward Jayaraj
Messages: 7 Registered: December 1999
|
Junior Member |
|
|
I have made a few changes to your code, Try this and I hope it will help you.
Note: v_report_date variable should be declared as
a varchar2 field.
FOR i in 1..45 LOOP
SELECT TO_CHAR((sysdate - 45 + i),'mm/dd/yyyy hh:mi:ss AM')
INTO v_report_date
FROM DUAL ;
FOR v_getlclsrv_rec IN c_getlclsrv
LOOP
INSERT INTO Fault.Local_dpms
VALUES
(v_getlclsrv_rec.ac, '0','0', '0',
TO_DATE(v_report_date,'mm/dd/yyyy hh:mi:ss AM'));
END LOOP;
END LOOP;
|
|
|