help NEEDED!!
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: help NEEDED!!

  1. #1
    Join Date
    Jun 2000
    Location
    dumfries,va,usa
    Posts
    227
    Hi,
    Can someone please help me in creating a procedure that will read in fields from 2 tables and populate 5 other tables for each record read from the 2 tables.
    Examples are most appreciated!


    Thanks,
    Leonard905
    leonard905
    leonard905@yahoo.com

  2. #2
    Join Date
    Aug 2001
    Location
    Waterloo, On
    Posts
    547
    CREATE OR REPLACE PROCEDURE PROC1
    IS

    rem -declare cursor

    CURSOR MY_CURSOR IS

    rem -your select statement for selecting records from the two tables. Eg

    SELECT BANKMAIN_MASTER.ACCNO, RDMAST.OPENING_DATE,
    RDMAST.NO_OF_MONTHS, RDMAST.MATURITY_DATE
    FROM
    BANKMAIN_MASTER, RDMAST
    WHERE
    RDMAST.ACCNO=BANKMAIN_MASTER.ACCNO;

    BEGIN
    FOR MYV IN MY_CURSOR LOOP

    INSERT INTO TABLE1(COLUMN1) VALUES(MYV.COLUMN_NAME);
    INSERT INTO TABLE2(COLUMN2) VALUES(MYV.COLUMN_NAME);
    INSERT INTO TABLE3(COLUMN3) VALUES(MYV.COLUMN_NAME);
    INSERT INTO TABLE4(COLUMN4) VALUES(MYV.COLUMN_NAME);
    INSERT INTO TABLE5(COLUMN5) VALUES(MYV.COLUMN_NAME);

    END LOOP;
    COMMIT;
    END;


    If the two tables from which you wish to select data are not joined, you have to declare two seperate cursors viz MYCURSOR1 and MYCURSOR2.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width