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: Help me with SQL

Re: Help me with SQL

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Fri, 22 Jan 1999 13:57:29 GMT
Message-ID: <36a882b2.167402702@inet16.us.oracle.com>


On 20 Jan 1999 19:55:52 GMT, "Scanavino Roberto" <roberto.scanavino_at_rsisistemi.it> wrote:

>
>
>Peraphs I'm stupid but I don't now how solve following problem....
>
>I'have a table with 2 column, d Date and c VARCHAR2(1);
>
>Can I insert one month in only one SQL instruction or I must use a
>procedure like this :
>
>d := to_date('01011999', 'mmddyyyy');
>for i in 1..31 loop
> INSERT INTO table values (d, 'A');
> d := d +1;
>end loop;

Try this:

insert into table ( dateField, varchar2Field ) select to_date('01011999', 'mmddyyyy')+rownum-1, 'A',   from some_table_with at least_31_columns  where rownum<32

eg.

SQL> desc t     
 Name                            Null?    Type
 ------------------------------- -------- ----
 D                                        DATE
 V                                        VARCHAR2(10)

SQL> insert into t ( d, v )
  2 select to_date('01011999', 'mmddyyyy')+rownum-1, 'A'   3 from all_objects
  4 where rownum < 32;
31 rows created.

SQL> select * from t;

D V

--------- ----------
01-JAN-99 A
02-JAN-99 A
03-JAN-99 A
04-JAN-99 A
05-JAN-99 A
06-JAN-99 A
07-JAN-99 A
08-JAN-99 A
09-JAN-99 A
10-JAN-99 A
11-JAN-99 A
12-JAN-99 A
13-JAN-99 A
14-JAN-99 A
15-JAN-99 A
16-JAN-99 A
17-JAN-99 A
18-JAN-99 A
19-JAN-99 A
20-JAN-99 A
21-JAN-99 A
22-JAN-99 A
23-JAN-99 A
24-JAN-99 A
25-JAN-99 A
26-JAN-99 A
27-JAN-99 A
28-JAN-99 A
29-JAN-99 A
30-JAN-99 A
31-JAN-99 A

31 rows selected.

Hope this helps.

chris.

>
>Roby
>
>Roberto.Scanavino_at_rsisistemi.it

--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Fri Jan 22 1999 - 07:57:29 CST

Original text of this message

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