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

Home -> Community -> Mailing Lists -> Oracle-L -> AW: Question about cursors

AW: Question about cursors

From: Kulev, Milen <Milen.Kulev_at_BusinessMart.de>
Date: Fri, 15 Aug 2003 05:21:46 -0800
Message-ID: <F001.005CAE99.20030815052146@fatcity.com>


Hello Roland,
Supposing that you want to select from table A and insert into B /or any ather table/. here is a samll example :

DECLARE

  TYPE id_type          IS TABLE OF A.id%TYPE;
  t_id           id_type;

BEGIN
  SELECT id
  BULK COLLECT INTO t_id FROM A where id > 10 ;    

    FORAll id IN t_id.FIRST .. t_id.LAST

       insert into B(id) values(t_id(id));     commit ;    

END;
/

HTH. Milen
-----Ursprüngliche Nachricht-----
Von: roland.skoldblom_at_ica.se [mailto:roland.skoldblom_at_ica.se] Gesendet: Freitag, 15. August 2003 13:39 An: Multiple recipients of list ORACLE-L Betreff: Question about cursors

Hallo,

I would like to get a goood example on how to do this in a pl/sql block, maybe this is too simple but I cant get it work.

I would like to do a select from table A, like this

select id from A
where id > 10

This sql statement gives me about 10 rows. I want those rows(the id) to be inserted in a table called A. I woul dlike to use variables to store al the id's that the sql gets me.

so the values to be inserted in the table should be for instance

11
12
13
14
15
16
17
18
19
20

How can I do this, using a cutsor I guess. Please give me an example.

Thanks in advance

Roland

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author:
  INET: roland.skoldblom_at_ica.se

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Kulev, Milen
  INET: Milen.Kulev_at_BusinessMart.de
Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Aug 15 2003 - 08:21:46 CDT

Original text of this message

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