Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Inserting Records Into a table
B. Williams wrote:
> I have created a table with two columns and one of the columns is the month
> and the other is the date. I want to use a pl/sql program to insert the
> months and dates into the table using a loop instead of using a bunch of
> insert statements.Will someone assist me with this? If I can get some help
> with January, I can figure the rest of the months out.
>
> Thanks
Why two columns to do one column's work?
SELECT SYSDATE, TO_CHAR(SYSDATE, 'MON'), TO_CHAR(SYSDATE, 'MM'),
TO_CHAR(SYSDATE, 'MONTH')
FROM dual;
And using PL/SQL to do this is even more backwards.
But assuming this is just a self-education exercise:
CREATE TABLE t (
datecol DATE);
BEGIN
FOR i IN 1..10 LOOP
INSERT INTO t (datecol) VALUES(SYSDATE+i);
SELECT * FROM t;
-- Daniel Morgan University of Washington Puget Sound Oracle Users GroupReceived on Thu Sep 07 2006 - 11:50:34 CDT
![]() |
![]() |