Home » RDBMS Server » Server Administration » inserting a date
inserting a date [message #370649] Fri, 14 January 2000 15:52 Go to next message
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 Go to previous messageGo to next message
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 Go to previous message
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;
Previous Topic: Need to sum char field in SQLPLUS
Next Topic: Calling Stored Procedures from ASP page.
Goto Forum:
  


Current Time: Tue Oct 20 10:20:12 CDT 2020