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

  • SEARCH
  • Home
  • 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 219823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:52:51+00:00 2026-05-11T18:52:51+00:00

I am following these steps, but I continue to get an error and don’t

  • 0

I am following these steps, but I continue to get an error and don’t see the issue:

1) Create a custom Oracle datatype that represents the database columns that you want to retrieve:

CREATE TYPE my_object AS OBJECT
     (COL1       VARCHAR2(50),
      COL2       VARCHAR2(50),
      COL3       VARCHAR2(50));

2) Create another datatype that is a table of the object you just created:


    TYPE MY_OBJ_TABLE AS TABLE OF my_object;

3) Create a function that returns this table. Also use a pipeline clause so that results are pipelined back to the calling SQL, for example:


    CREATE OR REPLACE
    FUNCTION MY_FUNC (PXOBJCLASS varchar2)
    RETURN MY_OBJ_TABLE pipelined IS
    TYPE ref1 IS REF CURSOR
    Cur1 ref1,
    out_rec_my_object := my_object(null,null,null);
    myObjClass VARCHAR2(50);
    BEGIN
    myObjClass := PXOBJCLASS
    OPEN Cur1 For ‘select PYID, PXINSNAME, PZINSKEY from PC_WORK where PXOBJCLass = ;1’USING myObjClass,
    LOOP
        FETCH cur1 INTO out_rec.COL1, out_rec.COL2, out_rec.COL3;
        EXIT WHEN Cur1%NOTFOUND;
        PIPE ROW (out_rec);
    END LOOP;
    CLOSE Cur1;
    RETURN;
    END MY_FUNC; 

NOTE: In the example above, you can easily replace the select statement with a call to another stored procedure that returns a cursor variable.

4) In your application, call this function as a table function using the following SQL statement:

select COL1, COL2, COL3 from TABLE(MY_FUNC('SomeSampletask'));
  • 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-11T18:52:52+00:00Added an answer on May 11, 2026 at 6:52 pm

    There is no need to use dynamic sql (dynamic sql is always a little bit slower) and there are too many variables declared. Also the for loop is much easier. I renamed the argument of the function from pxobjclass to p_pxobjclass.

    Try this:

    create or replace function my_func (p_pxobjclass in varchar2)
    return my_obj_table pipelined
    is 
    begin
      for r_curl in (select pyid,pxinsname,pzinskey 
                     from   pc_work
                     where  pxobjclass = p_pxobjclass) loop
        pipe row (my_object(r_curl.pyid,r_curl.pxinsname,r_curl.pzinskey));          
      end loop;
      return; 
    end; 
    

    EDIT1:

    It is by the way faster to return a ref cursor instead of a pipelined function that returns a nested table:

    create or replace function my_func2 (p_pxobjclass in varchar2)
    return sys_refcursor
    is 
      l_sys_refcursor sys_refcursor; 
    begin
      open l_sys_refcursor for 
        select pyid,pxinsname,pzinskey 
        from   pc_work
        where  pxobjclass = p_pxobjclass;
      return l_sys_refcursor;  
    end;
    

    This is faster because creating objects (my_object) takes some time.

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

Sidebar

Related Questions

How would you call the constructor of the following class in these three situations:
I have the following regex: (?!^[&#]*$)^([A-Za-z0-9-'.,&@:?!()$#/\\]*)$ So allow A-Z, a-Z, 0-9, and these special
Is there a better way than the following to check to see if a
I understand the following elements : there is some sort of crawling (configured in
I have the following situation: There is a tool that gets an XSLT from
I am trying to find an optimal solution for the following problem: there is
Is there any difference to the following code: class Foo { inline int SomeFunc()
Is there any performance penalty for the following code snippet? for (int i=0; i<someValue;
Is there a way to do the following using LINQ? foreach (var c in
Is there a way to bypass the following IE popup box: The webapge you

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.