DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Cursor to Table

  1. #1
    Join Date
    Sep 2005
    Posts
    3

    Cursor to Table

    Hi,
    Please let me know how to insert data from a cursor to a table

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    what code have you tried so far? what is your cursor definition?
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Sep 2005
    Posts
    3

    Cursor to Table

    Slimdave,
    For example: I created a table:EMP_1 with data in it and table:EMP_2 with NO data in it. Structures are same.
    AND, I used the following code to insert data from EMP_1 to EMP_2.
    -------------
    BEGIN
    DECLARE
    CURSOR prev_rec IS
    SELECT EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,SEQ_ID
    FROM EMP_1;
    BEGIN
    FOR cur_rec IN prev_rec
    LOOP
    INSERT INTO EMP_2 values(cur_rec.EMPNO,cur_rec.ENAME,cur_rec.
    JOB,cur_rec.MGR,cur_rec.HIREDATE,
    cur_rec.SAL,cur_rec.COMM,cur_rec.DEPTNO,
    cur_rec.SEQ_ID);
    END LOOP;
    END;
    END;
    ------------------------
    When I used at SQL prompt, it is working OK (inserting data from EMP_1 to EMP_2).
    BUT...
    When I used the same code in a Oracle Form Trigger, it is not working, WHY& What am I missing ?

  4. #4
    Join Date
    Sep 2005
    Posts
    3

    Cursor to Table

    Slimdave,
    Nevermind........I got it
    Thanks anyway

  5. #5
    Join Date
    May 2005
    Posts
    129
    Why not just Select Into ? or CTAS ?

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