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

Thread: Cursors & Pro* C

  1. #1
    Join Date
    Apr 2001
    Posts
    13
    I need to select certain fields from various tables, format them and dump them into a commen table using Pro* C. I know i can do this by fetching the fields into a cursor and then inserting the entire cursor into the new table. What i don't know is, if i can use cursors in Pro* C. And if I can, HOW? Please, somebody reply soon.

    Thanx in advance.
    Khurram.

  2. #2
    Join Date
    May 2001
    Location
    San Francisco, California
    Posts
    511
    PRO*C cursors have the same 4 steps as a regular PL/SQL:

    DECLARE:

    EXEC SQL DECLARE emp_cursor CURSOR FOR
    SELECT ename, empno, sal
    FROM emp
    WHERE deptno = :dept_number;

    OPEN:

    EXEC SQL OPEN emp_cursor;

    FETCH:

    EXEC SQL FETCH emp_cursor
    INTO :emp_name, :emp_number, :salary;

    CLOSE:

    EXEC SQL CLOSE emp_cursor;

    You handle the cursor not found by

    EXEC SQL WHENEVER NOT FOUND..

    Hope this helps.

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