Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 319943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:42:28+00:00 2026-05-12T08:42:28+00:00

I’m a little bit new to PL/SQL and need something that looks a bit

  • 0

I’m a little bit new to PL/SQL and need something that looks a bit like this:

create type base as object (
  unused number,
  member procedure p( c in ref cursor )
) not final;

create type child1 under base (
  overriding member procedure p( c in ref cursor ) as
    t table1%rowtype
  begin
    fetch c into t;
    -- process table1 row
  end;
);

create type child2 under base (
  overriding member procedure p( c in ref cursor ) as
    t table2%rowtype
  begin
    fetch c into t;
    -- process table2 row
  end;
);

procedure generic_handler( o in base, c in ref cursor ) as
begin
  o.p( c );
end;

o1 child1 := child1(0)
o2 child2 := child2(0)

c ref cursor
open c for select * from table1;
generic_handler( o1, c );

open c for select * from table2;
generic_handler( o2, c );

Basically, I need a single generic routine that knows how to perform a table-independent action delegating table-specific tasks to a derived class.

The above object methods taking ‘ref cursor’s don’t compile – compiler says ‘cursor needs to be defined’. So of course I’ve tried ‘type generic_cursor as ref cursor’ all over the place but can’t get it to compile.

I found pretty much nothing when trying to track down the syntax for passing ref cursors to object methods. And this made me think that perhaps I’m trying to do something stupid.

Does what I’m trying to do make sense? If so, what am I missing? Where can I define the generic_cursor so that I can use it as an object method parameter type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:42:29+00:00Added an answer on May 12, 2026 at 8:42 am

    Your code will work once you sort out the syntactical errors.

    SQL> create or replace type base as object
      2  (  unused number
      3      ,  member procedure p( c in sys_refcursor )
      4  )
      5  not final;
      6  /
    
    Type created.
    
    SQL>
    SQL> create or replace type child1 under base (
      2      overriding member procedure p( c in sys_refcursor )
      3  );
      4  /
    
    Type created.
    
    SQL> create or replace type body child1 as
      2      overriding member procedure p( c in sys_refcursor )
      3          as
      4              t dept%rowtype;
      5          begin
      6              loop
      7                  fetch c into t;
      8                  exit when c%notfound;
      9                  dbms_output.put_line('dname='||t.dname);
     10              end loop;
     11          end;
     12  end;
     13  /
    
    Type body created.
    
    SQL>
    SQL> create or replace type child2 under base (
      2      overriding member procedure p( c in sys_refcursor )
      3   );
      4  /
    
    Type created.
    
    SQL> create or replace type body child2 as
      2      overriding member procedure p( c in sys_refcursor )
      3          as
      4              t emp%rowtype;
      5          begin
      6              loop
      7                  fetch c into t;
      8                  exit when c%notfound;
      9                  dbms_output.put_line('ename='||t.ename);
     10              end loop;
     11          end;
     12  end;
     13  /
    
    Type body created.
    
    SQL>
    SQL>
    SQL> create or replace procedure generic_handler
      2          ( o in out base, c in sys_refcursor )
      3          as
      4  begin
      5      o.p( c );
      6  end;
      7  /
    
    Procedure created.
    
    SQL>
    SQL> set serveroutput on size unlimited
    SQL>
    SQL> declare
      2      o1 child1 := child1(0);
      3      o2 child2 := child2(0);
      4      rc sys_refcursor;
      5  begin
      6      open rc for select * from dept where deptno = 10;
      7      o1.p(rc);
      8      open rc for select * from emp where deptno = 10;
      9      o2.p(rc);
     10  end;
     11  /
    dname=ACCOUNTING
    ename=BOEHMER
    ename=SCHNEIDER
    ename=KISHORE
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    The Oracle documentation is pretty hard to understand when you’re new. I think in your case you need to know that the Object_Oriented stuff is in a different book from the regular PL/SQL information. You will probably need to check both whenever you’re stumped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.