Results 1 to 6 of 6

Thread: Cursors in packages

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Contributing Member
    Join Date
    Mar 2008
    Answers
    66

    Cursors in packages

    Can we specify return type for Static cursors? If yes Can any one give example?

    Last edited by babi_geek; 06-07-2008 at 05:30 AM.

  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Cursors in packages

    please find a related article here.


  3. #3
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Cursors in packages

    Yes we can.
    Here is the example

    Code:
     
    create or replace procedure test_proc is 
    
    cursor c1 return dept%rowtype is 
    select * from dept where deptno = 10; 
    
    dept_rec dept%rowtype; 
    
    begin 
    
    open c1; 
    
    fetch c1 into dept_rec; 
    
    dbms_output.put_line ('department name is ' || dept_rec.dname); 
    
    close c1; 
    end; 
    /


    Last edited by krishnaindia2007; 06-11-2008 at 11:53 PM.

  4. #4
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Cursors in packages

    You can specify return type for static cursors. But you can't return a value using static cursors.

    Last edited by krishnaindia2007; 06-12-2008 at 12:03 AM.

  5. #5
    Contributing Member
    Join Date
    Mar 2008
    Answers
    66

    Re: Cursors in packages

    So far I think return type specification is allowed only for ref cursors.

    Then can we define static cursors in package specification part?


  6. #6
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Cursors in packages

    >>Then can we define static cursors in package specification part?

    Yes you can.

    CREATE PACKAGE emp_pkg IS
    CURSOR C1 RETURN emp%rowtype ;
    .......
    END;
    /


    CREATE OR REPLACE PACKAGE BODY emp_pkg AS
    cursor c1 return emp%rowtype is
    select * from emp;
    .......
    END EMP_PKG;
    /


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact