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: PL/SQL help

Re: PL/SQL help

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Thu, 28 Sep 2006 17:55:53 +0200
Message-ID: <451bf089$0$25544$626a54ce@news.free.fr>

"RJ" <ridwan.jeena_at_gmail.com> a écrit dans le message de news: 1159427739.862730.228360_at_h48g2000cwc.googlegroups.com...
| Hi all,
|
| I have the follwoing table (abc):
|
| NAME NO_CASES
| --------- -------------------
|
| Smith 13
| John 9
| Mary 5
| Kate 23
|
| I want to insert into another table (xyz) as follows:
|
| Smith must be inserted 13 times (13 rows), John 9 times (9 rows) etc..
| for all the records in the table.
|
| How will I do this?
|
| Thanks in advance...
|

SQL> select * from t2;
NOM NO_CASES
---------- ----------

Smith               2
John                3
Mary                2
Kate                1

4 rows selected.

SQL> with
  2 rn as (

  3      select rownum rn from dual
  4      connect by level <= (select max(no_cases) from t2)
  5 )
  6 select nom
  7 from t2, rn
  8 where rn <= no_cases
  9 order by nom
 10 /
NOM

John
John
John
Kate
Mary
Mary
Smith
Smith

8 rows selected.

Regards
Michel Cadot Received on Thu Sep 28 2006 - 10:55:53 CDT

Original text of this message

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