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 8823371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:20:16+00:00 2026-06-14T06:20:16+00:00

I have the following types: CREATE OR REPLACE TYPE num_t AS OBJECT ( c1

  • 0

I have the following types:

CREATE OR REPLACE TYPE num_t AS OBJECT
(
  c1 number,
  MAP MEMBER FUNCTION sort_key RETURN VARCHAR2
)
CREATE OR REPLACE TYPE BODY num_t AS
   MAP MEMBER FUNCTION sort_key RETURN VARCHAR2 IS
   BEGIN
      RETURN c1;
   END;
END;

and

CREATE OR REPLACE TYPE num_tab AS TABLE OF num_t

My package is defined as follows:

create or replace package test_package is

  type t_test is table of number index by binary_integer;
  test_empty_array t_test;

  procedure test_proc(cur_out out sys_refcursor);

  function test_fn(i_test in t_test) return num_tab;

end test_package;

create or replace package body test_package is

  procedure test_proc(cur_out out sys_refcursor) is
    i_test t_test := test_empty_array;
  begin
    open cur_out for
      select * from table(test_fn(i_test));

  end;

  function test_fn(i_test in t_test) return num_tab is
    v_results num_tab;
  begin
    for i in i_test.first .. i_test.last loop
      v_results.extend;
      v_results(i) := num_t(c1 => i_test(i));
    end loop;

    return v_results;
  end;

end test_package;

When I try to compile this, I get the following errors:

Error: PLS-00382: expression is of wrong type
Line: 7
Text: select * from table(test_fn(i_test));

Error: PLS-00306: wrong number or types of arguments in call to 'TEST_FN'
Line: 7
Text: select * from table(test_fn(i_test));

Error: PL/SQL: ORA-00904: "TEST_PACKAGE"."TEST_FN": invalid identifier
Line: 7
Text: select * from table(test_fn(i_test));

Error: PL/SQL: SQL Statement ignored
Line: 7
Text: select * from table(test_fn(i_test));

It looks like it should work to me. Any ideas?

  • 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-06-14T06:20:18+00:00Added an answer on June 14, 2026 at 6:20 am

    this is normal and expected. functions used in SQL can only reference SQL datatypes (eg you’d get an error if you had a boolean datatype too).

    you can hide it in the package:

    create or replace package test_package is
    
      type t_test is table of number index by binary_integer;
      test_empty_array t_test;
    
      procedure test_proc(cur_out out sys_refcursor);
    
      function test_fn(i_test in t_test) return num_tab;
    
    end test_package;
    /
    create or replace package body test_package is
    
      procedure test_proc(cur_out out sys_refcursor) is
        i_test t_test := test_empty_array;
        t_num  num_tab;
      begin
        t_num := test_fn(i_test);
        open cur_out for
          select * from table(t_num);
    
      end;
    
      function test_fn(i_test in t_test) return num_tab is
        v_results num_tab := num_tab();
      begin
        for i in 1..i_test.count loop
          v_results.extend;
          v_results(i) := num_t(c1 => i_test(i));
        end loop;
    
        return v_results;
      end;
    
    end test_package;
    /
    

    i also tweaked

    v_results num_tab := num_tab();
    

    and

    for 1..i_test.count loop
    

    as first..last would fail in the case of a blank array (numeric error)

    eg with some data:

    SQL> create or replace package body test_package is
      2
      3    procedure test_proc(cur_out out sys_refcursor) is
      4      i_test t_test;
      5      t_num  num_tab;
      6    begin
      7      i_test(1) := 1;
      8      i_test(2) := 3;
      9      t_num := test_fn(i_test);
     10      open cur_out for
     11        select * from table(t_num);
     12
     13    end;
     14
     15    function test_fn(i_test in t_test) return num_tab is
     16      v_results num_tab := num_tab();
     17    begin
     18      for i in 1..i_test.count loop
     19        v_results.extend;
     20        v_results(i) := num_t(c1 => i_test(i));
     21      end loop;
     22
     23      return v_results;
     24    end;
     25
     26  end test_package;
     27  /
    
    Package body created.
    
    SQL> exec test_package.test_proc(:c)
    
    PL/SQL procedure successfully completed.
    
    SQL> print c
    
            C1
    ----------
             1
             3
    
    SQL>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following function: create or replace FUNCTION MXUPGKEYVAL(tbname varchar2,colname varchar2) return number
I have the following function: CREATE OR REPLACE FUNCTION GetVarchar2 (iclCLOB IN Nvarchar2) return
I have create the following tables and types.... CREATE TYPE ACTOR_QUOTE_TYPE AS OBJECT (
I have the following type and function: CREATE OR REPLACE TYPE SERIAL_NUMBER_TABLE AS TABLE
I have the following code: CREATE OR REPLACE FUNCTION repeatable_rand_text(ftype IN VARCHAR2 , in_val
I have a user-defined type: create or replace type my_message_type as object (relatedid varchar2(50),
i have a type as follows: CREATE OR REPLACE TYPE tbusiness_inter_item_bag AS OBJECT (
I have the following code to return multiple values from pl/python: CREATE TYPE named_value
I have the following PostgreSQL script: CREATE OR REPLACE FUNCTION merge_fields() RETURNS VOID AS
For strongly-typed & type-safe solution, I have to do the following step. Create some

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.