From cursor to a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vamsioracle
    New Member
    • Jun 2007
    • 151

    From cursor to a table

    Hi All


    Recently i was working on cursors in a procedure. I was using a cursor in a procedure to retrieve names and corresponding Ids. I used loop to fetch each record into an OUT variable. But I want all the names to be directly stored into a temporary table(created by myself, which has only one field for storing the names). I want to use this temporary table later at the front end application.


    this was my code snippet
    ------------------------------------------------------------------------------------------------
    CREATE Procedure HRMS ( id out varchar2,name out varchar2 )
    IS
    cursor c1 is
    select PROJ_Id,LAST_NA ME from HRMS_TABLE where LAST_name LIKE s%;
    BEGIN
    open c1;
    LOOP
    fetch c1 into ID,NAME;
    exit when c1%NOTFOUND;
    END LOOP;
    close c1;
    end;
    ----------------------------------------------------------------------------------------------
    Please someone help regarding this. I hope i get an Reply for this as soon as possible.

    Thank u
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by vamsioracle
    Hi All


    Recently i was working on cursors in a procedure. I was using a cursor in a procedure to retrieve names and corresponding Ids. I used loop to fetch each record into an OUT variable. But I want all the names to be directly stored into a temporary table(created by myself, which has only one field for storing the names). I want to use this temporary table later at the front end application.


    this was my code snippet
    ------------------------------------------------------------------------------------------------
    CREATE Procedure HRMS ( id out varchar2,name out varchar2 )
    IS
    cursor c1 is
    select PROJ_Id,LAST_NA ME from HRMS_TABLE where LAST_name LIKE s%;
    BEGIN
    open c1;
    LOOP
    fetch c1 into ID,NAME;
    exit when c1%NOTFOUND;
    END LOOP;
    close c1;
    end;
    ----------------------------------------------------------------------------------------------
    Please someone help regarding this. I hope i get an Reply for this as soon as possible.

    Thank u
    If I got your question right, then all you need to do is to put the insert statement between the fetch line and the exit when line. Are you having problems with the insert statement?

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Please find more details regarding cursors here.

      Comment

      • vamsioracle
        New Member
        • Jun 2007
        • 151

        #4
        Originally posted by debasisdas
        Please find more details regarding cursors here.



        thank you very much. That was a timely help

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Hi
          vamsioracle
          Welcome to TSDN.

          You have reached the right place for knowledge shairing.

          Here you will find a vast resource of related topics and code.

          Feel free to post more doubts/questions in the forum.

          But before that give a try from your side and if possible try to post what/how you have approached to solve the problem.

          It will help Experts in the forum in solving/underestanding your problem in a better way.

          Please follow the posting guidelines in every new post/reply.

          Regards

          Debasis

          Comment

          Working...