Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Inserting Records Into a table

Re: Inserting Records Into a table

From: DA Morgan <damorgan_at_psoug.org>
Date: Thu, 07 Sep 2006 09:50:34 -0700
Message-ID: <1157647831.249454@bubbleator.drizzle.com>


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);

   END LOOP;
   COMMIT;
END;
/

SELECT * FROM t;

-- 
Daniel Morgan
University of Washington
Puget Sound Oracle Users Group
Received on Thu Sep 07 2006 - 11:50:34 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US