Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Insert 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
You do not need pl/sql or a bunch of SQL statements.
Take a look at the following query and see if you cannot figure out a way to convert it into an update statement.
1 select to_char(to_date('01-JAN-06') + a.increase,'MONTH') 2 ,to_char(to_date('01-JAN-06') + a.increase,'DD') 3 from (select rownum as increase from all_objects 4* where rownum < 366) A
DECEMBER 28
DECEMBER 29
DECEMBER 30
DECEMBER 31
JANUARY 01
365 Rows selected
See the SQL manual for the complete list of format options for the to_char and to_date functions plus look up add_months, last_day, and trunc.
HTH -- Mark D Powell -- Received on Thu Sep 07 2006 - 12:04:40 CDT
![]() |
![]() |