RETURN type of function table

Hello

I read conflicting information about the return type that has a table function must or may use.

First, I am a student of a book that says:

Function in pipeline returns the data types:

The main constraint for the pipeline functions, it is the return type must be a collection type autonomous which can be used in SQL - i.e. a VARRAY or table nested.

and then in the next sentence...

More precisely a pipeline function can return the following:

A stand-alone nested table or VARRAY, defined at the schema level.

A nested table or VARRAY that has been declared in a package type.

This seems to go against the first quoted sentence.

Now, before reading the above text I had done just my own test to see if a packed type would work because I thought I had read somewhere that it would not, and he does not (the test code and this output is at the end of this question). When I arrived in the text above, after my test, so I was naturally confused.

So, I'm going to PL/SQL reference that says:

RETURN data type

The data type of the value returned by a function table in pipeline must be a type collection defined either at the level of schema or within a package (therefore, it cannot be a type of associative array).

I tried to call a function that returns a collection of VARRAY type packaged in both SQL and PL/SQL (of course below is SQL all in any case) and no work.

Now I'm wondering what is a TABLE function must use a schema type and a function table in pipeline can use a packaged type?  I see that I created and called a function table but examples of Oracle see the creation and use of a function table in pipeline.

Edit: I should add that I read the following sentence in the SF book on p609 in * table functions: "this type of nested table must be defined as an element of level diagram, because the SQL engine must be able to resolve a reference to a collection of this kind."

So that it begins to resemble table functions should return a schema type and pipelined table functions, perhaps because that they don't in fact return a collection, rather they return (RowSource) content, can use the schema types or types of packages. Is this correct?

Can someone clarify this for me please?

Thank you in advance,

J

CREATE OR REPLACE PACKAGE PKGP28M

VAT-type is varray (5) number;

END;

/

DISPLAY ERRORS

create or replace type VAT is varray (5) number;

/

display errors

create or replace function tabfunc1 return pkgp28m.vat as

numtab pkgp28m.vat:=pkgp28m.vat();

Start

numtab.extend (5);

because loop me in 1.5

numtab (i): = trunc (dbms_random. Value (1.5));

end loop;

Return numtab;

end;

/

display errors

create or replace function tabfunc2 as return VAT

numtab vat:=vat().

Start

numtab.extend (5);

because loop me in 1.5

numtab (i): = trunc (dbms_random. Value (1.5));

end loop;

Return numtab;

end;

/

display errors

exec dbms_output.put_line (' call tabfunc1 (returns the packaged type) :');)

Select * from table (tabfunc1)

/

exec dbms_output.put_line (' call tabfunc2 (returns the type of schema) :');)

Select * from table (tabfunc2)

/

declare

RC sys_refcursor;

number of v;

Start

dbms_output.put_line (' in anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type) :');)

Open rc to select table column_value (tabfunc1);

loop

extract the rc in v;

When the output rc % notfound;

dbms_output.put_line (' > ' | to_char (v));

end loop;

close the rc;

end;

/

declare

RC sys_refcursor;

number of v;

Start

dbms_output.put_line (' in anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema) :');)

Open rc to select table column_value (tabfunc2);

loop

extract the rc in v;

When the output rc % notfound;

dbms_output.put_line (' > ' | to_char (v));

end loop;

close the rc;

end;

/

Scott@ORCL > @C:\Users\J\Documents\SQL\test29.sql

Package created.

No errors.

Type of creation.

No errors.

The function is created.

No errors.

The function is created.

No errors.

the call of tabfunc1 (returns the packaged type):

PL/SQL procedure successfully completed.

Select * from table (tabfunc1)

*

ERROR on line 1:

ORA-00902: invalid data type

the call of tabfunc2 (returns the type of schema):

PL/SQL procedure successfully completed.

COLUMN_VALUE

------------

1

4

1

1

3

In anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type):

declare

*

ERROR on line 1:

ORA-00902: invalid data type

ORA-06512: at line 6

In anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema):

> 1

> 2

> 4

> 2

> 3

PL/SQL procedure successfully completed.

Post edited by: Jason_942375

But the compilation of the PIPELINED WILL CREATE the schematic function types automatically. And the TABLE function, applied to the PIPELINED function, use these types of hidden patterns.

Tags: Database

Similar Questions

  • How to the return type of function from PL/SQL

    Hello

    I need to create a function that returns a list of ID, which is stored in a type T_IDs, something like:

    search function (searchstring in varchar2) return to T_IDs

    I have a little problem with the type within the body of the function using a select statement and filling

    Select the id of the table where the text as searchstring.

    which is to select a list of IDS corresponding to the where clause. Is it possible to use select in or should I go for another mechanism?

    Thanks for all the ideas.

    Bulk Collect works for me...

    SQL> create type t_ids as table of number;
      2  /
    
    Type created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create or replace function get_ids(deptno in number) return t_ids is
      2    ids t_ids;
      3  begin
      4    select empno
      5    bulk collect into ids
      6    from   emp
      7    where  deptno = get_ids.deptno;
      8    return ids;
      9* end;
    SQL> /
    
    Function created.
    
    SQL> select * from table(get_ids(10));
    
    COLUMN_VALUE
    ------------
            7782
            7839
            7934
    

    However, I would rarely use such a data collection, as it fills with PGA in memory and passing a lot of data between SQL and PL/SQL. I must have a just cause and justified in wanting to do things this way.

  • Doubt about the return type of function

    Hello

    Can a function returns a Boolean value in a select query.

    Suppose m creating a function... so can we have a return type of Boolean as...?

    If so... THN please give an example

    Can a function returns a Boolean value in a select query

    The answer is no. a Boolean is not a SQL data type and may not be used in the SELECT query.
    For the user-defined function to be called in a SQL statement, see http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_packages.htm#ADFNS00908
    Note especially these lines

    "Its formal parameters and its return value (if any) must have built-in data types (for example, CHAR, DATE or NUMBER) Oracle, not types (such as BOOLEAN, RECORD or TABLE) PL/SQL data.

    "There is an exception to this rule: a formal parameter can have a PL/SQL data type, if the corresponding actual parameter is implicitly converted to the data type of the formal parameter" >

    Published by: Johan August 3, 2010 03:48

  • With the help of a user defined type as a return type of function with a type of object

    Hi, I created my own data type of table I want to use as data type back to a member function of an object type that I created.

    I work in an environment of 10g.

    The code I used looks like this:

    create or replace
    Dim p As Package as

    type p_rec is (number of v1);
    type p_tab is table of the p_rec;

    end p;
    /

    CREATE or REPLACE TYPE p_ot () AS OBJECT

    / * some statements * /.

    NO DEFINITIVE MEMBER FUNCTION p.p_tab RETURN foo

    );
    /


    When I try to compile p_ot I get an error: Error (5.40): PLS-00201: identifier 'P.P_TAB' must be declared.

    I don't know the syntax is correct so I must be missing something, amy hepl would be great.

    See you soon

    You can define types of objects

    create type p_rec as object ( v1 number );
    create type p_tab as table of p_rec;
    

    They can be used inside the package (p) in your example) as well as defined in the package.
    In this case, there will be no problems with create type

    CREATE TYPE p_ot AS OBJECT (
    
    /* some declarations*/
    
    NOT FINAL MEMBER FUNCTION foo RETURN p_tab
    );
    
  • Question of functions table

    Hello people,

    I just want to know why I can't use indexed tables in the table as return type functions. For example when I write "pls_integer index" at the end of the holder_t code, table function does not work. I would like to know why? What are the differences?

    create or replace
    package my_pack
    is
    type holder_t is table of Hello % rowtype;
    / * When I type this table like this, type holder_t is table of the Hello % rowtype index by pls_integer; table function does not work * /.
    type ref_cur_t is ref cursor
    Hello return % rowtype;
    end;

    create or replace
    function pipeline (SLEEP my_pack.ref_cur_t)
    parallel_enable my_pack.holder_t return pipeline (partition SLEEP by any)
    is
    my_row Hello % rowtype;
    holder hello_o: = hello_o (null, null);
    Start

    loop
    When the exit SLEEP % notfound;
    extract SLEEP them in my_row;
    Holder.a: = my_row.a;
    Holder.b: = my_row.b;
    course of action (my_row);
    end loop;
    Close SLEEP;

    return;

    end;



    Thank you.

    Polat says:
    OK, but what are the differences with the type holder_t is table of Hello % rowtype and type holder_t table with % rowtype index by pls_integer Hello? I mean both of them are table, but if I then use as return type it gives an error, I am trying to understand this?

    Difference is

    type holder_t is table of hello%rowtype index by pls_integer;
    

    Is an associative array. Similar to a hash table. This is only one type of PL/SQL, SQL cannot be used.

    This

    type holder_t is table of hello%rowtype;
    

    Is a nested table, similar to a set (or bag). This can be used in SQL, too.

    Looking at the docs for functions in pipeline, type that see you back:

    The data type of the value returned by a function table in pipeline must be a collection type defined at the schema or within a packet level (therefore, it cannot be a type of associative array).
    The elements of the collection type should be given SQL type, not data types supported only by the PL/SQL (for example PLS_INTEGER and BOOLEAN).

    Looking for all ther son you have on this topic, you should certainly read and try under rest three different collection types offered:
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/composites.htm#LNPLS00501

    Concerning
    Peter

  • Using the function PLSQL return Record Type Index of Tables in ADF

    I have a PLSQL function, a return type. My ultimate goal is to take this binary integer index Table and print it on the screen...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table ;
    END my_pkg;


    OPTION 1:

    1) has anyone got best practices to accept plsql RECORDS returned by a function?

    Here is an example.

    http://adfpractice-Fedor.blogspot.SG/2013/01/working-with-PLSQL-procedures-in-ADF-BC.html

    But it will be a lot of work... first of all accept the results in a loop... then store in a temporary storage can be a few VO or global temporary table and then display them on the page


    OPTION 2:

    Using the functions PIPLELINED and use in the select statement.  While I can use this select statement in the SQL query to create VO... and drag and drop the VO...

    CREATE OR REPLACE PACKAGE my_pkg IS
     
    TYPE t_col IS RECORD(
     
    i NUMBER,
     
    n VARCHAR2(30));
     
    TYPE t_nested_table IS TABLE OF t_col;
     
      FUNCTION return_table RETURN t_nested_table PIPELINED;
    END my_pkg;


    select * from table(my_pkg.return_table);


    Wow... I'm so smart! .. really possible?  who is the best/possible/recommended option?

    I'm sure that will be the question most read by many who wants to use PLSQL instead of JAVA to the treatment and CHOSEN to use only to display the output of the PLSQL functions or procedures.


    Thank you

    Rahul


    Dario

    Do you mean the scope of the defined Type pkg will be finished?

    I created guy outside the pkg as 'Create Type' if it works in this case?

    Yes, level objects schema (created with "create or replace type...") can be used in java and this can work.

    I think that then the scope of this TYPE will remain until the user session passes.

    Object definitions is not worn, but have their bodies.

    So, if you instantiate the data level object type schema in a plsql function, scope of this object is this function.

    Of course, if you instantiate the object as a variable package, then life of this object is equal to the lifetime of the package (which usually equals life of session db).

    Dario

  • a function that returns the type with a table joint!

    Good day to all,
    I have a function that returns a type.

    so I select it as:
    Select * from table (function (param1, param2))

    now I want to combine this with a table so that the settings for the service we get from the join table. Is this possible? And how?
    I tried different options without success.

    something like:
    Select *.
    table table (function (b.column1, b.columnb) x), tablea b
    where x.a = b.col

    Is this possible?

    Thanks in advance?

    user564819 wrote:

    something like:
    Select *.
    table table (function (b.column1, b.columnb) x), tablea b
    where x.a = b.col

    Is this possible?

    Somehow...

    SQL> create or replace type TIntegers is table of integer;
      2  /
    
    Type created.
    
    SQL>
    SQL> --// our sample pipeline simply spews 2 numbers for eevry number input - simple
    SQL> --// to use for the testcase below
    SQL> create or replace function FooPipe( n number ) return TIntegers pipelined is
      2  begin
      3          pipe row( trunc(n) );
      4          pipe row( trunc(n)*-1 );
      5          return;
      6  end;
      7  /
    
    Function created.
    
    SQL>
    SQL> with dataset( n ) as(
      2          --// ignore this part as it only builts a base table
      3          --// for us to use to select values for input to
      4          --// to the pipeline - in "real world" use this table
      5          --// will already exist
      6          select
      7                  level
      8          from    dual
      9          connect by level <= 10
     10  ),
     11  pipe_line( n, array ) as(
     12          --// we run the pipeline as a nested table column
     13          --// in the SQL projection - the CAST is important
     14          --// in order to establish the nested table type
     15          select
     16                  d.n,
     17                  cast(
     18                          FooPipe(d.n) as TIntegers
     19                  )
     20          from    dataset d
     21  )
     22  --// we now use a standard query to unnest the nested table column
     23  select
     24          p.n,
     25          pipe_val.*
     26  from       pipe_line p, TABLE(p.array)  pipe_val
     27  /
    
             N COLUMN_VALUE
    ---------- ------------
             1            1
             1           -1
             2            2
             2           -2
             3            3
             3           -3
             4            4
             4           -4
             5            5
             5           -5
             6            6
             6           -6
             7            7
             7           -7
             8            8
             8           -8
             9            9
             9           -9
            10           10
            10          -10
    
    20 rows selected.
    
    SQL>
    

    Not sure I like it. What is the real problem that this method (driving a pipeline with input of a base table rows) is supposed to address? There may be a simpler and more elegant approach...

  • From a function table: invalid data type error

    Hello

    I'm a ORA-00902: invalid data type error when I try to call the function from a select statement below. Here, I am leaving an array from a function.
    create or replace package pkg10
    as
    
    type tabletype1 is table of table1%rowtype
    index by binary_integer;
    
    function func1 return tabletype1;
    
    end pkg10;
    create or replace package body pkg10
    as
    
    function func1 return tabletype1 
    is
        v_tab1 tabletype1;
        idx integer;
    begin 
    
        idx := 1;
        
        for i in (select * from table1)
        loop
            v_tab1(idx).name1 := i.name1;
            v_tab1(idx).key := i.key;
            idx := idx+1;
            
        end loop;
    
    return v_tab1; 
    
    end func1; 
    
    end pkg10;
    select * from table(pkg10.func1);
    Please point out to me where I'm wrong.

    Thank you

    Sathya Vamsi says:
    Hello

    I'm a ORA-00902: invalid data type error when I try to call the function from a select statement below. Here, I am leaving an array from a function.

    create or replace package pkg10
    as
    
    type tabletype1 is table of table1%rowtype
    index by binary_integer;
    
    function func1 return tabletype1;
    
    end pkg10;
    
    create or replace package body pkg10
    as
    
    function func1 return tabletype1
    is
    v_tab1 tabletype1;
    idx integer;
    begin 
    
    idx := 1;
    
    for i in (select * from table1)
    loop
    v_tab1(idx).name1 := i.name1;
    v_tab1(idx).key := i.key;
    idx := idx+1;
    
    end loop;
    
    return v_tab1; 
    
    end func1; 
    
    end pkg10;
    
    select * from table(pkg10.func1);
    

    Please point out to me where I'm wrong.

    Thank you

    you try to use a data type of PL/SQL as part of an SQL statement. is NOT authorized.

  • PLS-00630: pipeline functions must have a collection of supported return type

    Hello, I created a TYPE of OBJECT and function PLSQL as shown below, but the function compile errors with that follows. Don't know where is the problem?
    PLS-00630: pipelined functions must have a supported collection return type
    It's about Oracle 10 g r2
    CREATE OR REPLACE TYPE cxs_plsql_profiler_object_type AS OBJECT (
       cxs_object_name      VARCHAR2 (128),
       cxs_object_type      VARCHAR2 (19),
       cxs_object_status    VARCHAR2 (7),
       cxs_read_execution   NUMBER,
       cxs_buffer_gets      NUMBER,
       cxs_disk_reads       NUMBER,
       cxs_executions       NUMBER,
       cxs_sorts            NUMBER,
       cxs_sharable_mem     NUMBER,
       cxs_address          NUMBER,
       cxs_hashvalue        NUMBER,
       cxs_osuser           VARCHAR2 (30),
       cxs_username         VARCHAR2 (30),
       cxs_module           VARCHAR2 (48),
       cxs_machine          VARCHAR2 (64),
       cxs_status           VARCHAR2 (8),
       cxs_terminal         VARCHAR2 (16),
       cxs_percentconsume   NUMBER,
       cxs_percentrepeat    NUMBER,
       cxs_plan             VARCHAR2 (120),
       target_name          VARCHAR2 (200),
       referenced_name      VARCHAR2 (200),
       referenced_type      VARCHAR2 (200),
       targetowner          VARCHAR2 (200),
       refowner             VARCHAR2 (200)
    )
    and here are the API
        FUNCTION CXS_GENERATE_PLSQL_PROFILER
    RETURN cxs_plsql_profiler_object_type
    PIPELINED IS
    out_rec cxs_plsql_profiler_object_type ;
    
    plsbatch plsql_batch;
    skount integer;
    dpendrec depend_tab;
    dkount integer;
    
    
    
    
    CURSOR objects
          IS
             SELECT object_name, object_type
               FROM dba_objects
              WHERE status = 'VALID'
                AND owner NOT IN ('SYS', 'SYSTEM')
                AND object_type IN ('PACKAGE', 'PROCEDURE', 'FUNCTION');
    
          CURSOR apis (p_object dba_objects.object_name%TYPE)
          IS
             SELECT DISTINCT *
                        FROM (SELECT   SUBSTR (a.sql_text, 1, 50) sql_text,
                                       TRUNC
                                          (  a.disk_reads
                                           / DECODE (a.executions,
                                                     0, 1,
                                                     a.executions
                                                    )
                                          ) reads_per_execution,
                                       a.buffer_gets, a.disk_reads, a.executions,
                                       a.sorts, a.sharable_mem, a.address,
                                       a.hash_value, b.osuser, b.username,
                                       b.module, b.machine, b.status, b.terminal,
                                       ROUND
                                          (cxs_db_info.kompute_percentofsql
                                                                   (a.sharable_mem),
                                           5
                                          ) percentkonsume,
                                       cxs_db_info.kount_repeat
                                                             (b.osuser,
                                                              b.terminal
                                                             ) percentr,
                                       c.operation explainplan
                                  FROM v$sqlarea a, v$session b, v$sql_plan c
                                 WHERE b.sql_hash_value = a.hash_value
                                   AND b.sql_address = a.address
                                   AND a.hash_value = c.hash_value
                                   AND a.address = c.address
                                   AND b.status = 'ACTIVE'
                                   AND UPPER (a.sql_text) LIKE
                                                            '%' || p_object || '%'
                                   AND c.ID = 0
                              ORDER BY 2 DESC)
                       WHERE ROWNUM <= 50;   --profile option
    BEGIN
    
    skount := 0;
    dkount := 0;
    
     FOR i IN objects
          LOOP
             FOR j IN apis (i.object_name)
             LOOP
                skount := skount + 1;
                plsbatch(skount).cxs_object_name  := i.object_name;
       plsbatch(skount).cxs_object_type      :=  i.object_type;
       plsbatch(skount).cxs_object_status    :=  i.object_status;
       plsbatch(skount).cxs_read_execution   := j.reads_per_execution;
       plsbatch(skount).cxs_buffer_gets      := j.buffer_gets;
       plsbatch(skount).cxs_disk_reads       := j.disk_reads;
       plsbatch(skount).cxs_executions       := j.executions;
       plsbatch(skount).cxs_sorts            := j.sorts;
       plsbatch(skount).cxs_sharable_mem     := j.sharable_mem;
       plsbatch(skount).cxs_address          := j.address;
       plsbatch(skount).cxs_hashvalue        := j.hashvalue;
       plsbatch(skount).cxs_osuser           := j.osuser;
       plsbatch(skount).cxs_username         := j.username;
       plsbatch(skount).cxs_module           := j.module;
       plsbatch(skount).cxs_machine          := j.machine;
       plsbatch(skount).cxs_status           := j.status;
       plsbatch(skount).cxs_terminal         := j.terminal;
       plsbatch(skount).cxs_percentconsume   := j.percentconsume;
       plsbatch(skount).cxs_percentrepeat    := j.percentrepeat;
       plsbatch(skount).cxs_plan             := j.explainplan;
             END LOOP;
    
             FOR dd IN dpend (i.object_name)
             LOOP
                dkount := dkount + 1;
                dependrec (dkount).target_name := dd.NAME;
                dependrec (dkount).refname := dd.referenced_name;
                dependrec (dkount).reftype := dd.referenced_type;
                dependrec (dkount).target_owner := dd.owner;
                dependrec (dkount).refowner := dd.referenced_owner;
             END LOOP;
          END LOOP;
    
    for a in 1..skount loop
    
       out_rec.cxs_object_type      := plsbatch(a).object_type;
       out_rec.cxs_object_status    := plsbatch(a).object_status;
       out_rec.cxs_read_execution   := plsbatch(a).reads_per_execution;
       out_rec.cxs_buffer_gets      := plsbatch(a).buffer_gets;
       out_rec.cxs_disk_reads       := plsbatch(a).disk_reads;
       out_rec.cxs_executions       := plsbatch(a).executions;
       out_rec.cxs_sorts            := plsbatch(a).sorts;
       out_rec.cxs_sharable_mem     := plsbatch(a).sharable_mem;
       out_rec.cxs_address          := plsbatch(a).address;
       out_rec.cxs_hashvalue        := plsbatch(a).hashvalue;
       out_rec.cxs_osuser           := plsbatch(a).osuser;
       out_rec.cxs_username         := plsbatch(a).username;
       out_rec.cxs_module           := plsbatch(a).module;
       out_rec.cxs_machine          := plsbatch(a).machine;
       out_rec.cxs_status           := plsbatch(a).status;
       out_rec.cxs_terminal         := plsbatch(a).terminal;
       out_rec.cxs_percentconsume   := plsbatch(a).percentconsume;
       out_rec.cxs_percentrepeat    := plsbatch(a).percentrepeat;
       out_rec.cxs_plan             := plsbatch(a).explainplan;
       PIPE ROW(out_rec);
    end loop;
    
    
    for b in 1..dkount loop
        out_rec.target_name := dd.NAME;
                out_rec.refname := dependrec (b).referenced_name;
                out_rec.reftype := dependrec (b).referenced_type;
                out_rec.target_owner := dependrec (b).owner;
                out_rec.refowner := dependrec (b).referenced_owner;
                PIPE ROW(out_rec);
     end loop;
    RETURN;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.format_error_backtrace);
    DBMS_OUTPUT.PUT_LINE(SQLCODE);
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    END; 
    and here's tradtional types of tables that are used in the code above.
     TYPE type_plsql_rec IS RECORD (
       cxs_object_name      VARCHAR2 (128),
       cxs_object_type      VARCHAR2 (19),
       cxs_object_status    VARCHAR2 (7),
       cxs_read_execution   NUMBER,
       cxs_buffer_gets      NUMBER,
       cxs_disk_reads       NUMBER,
       cxs_executions       NUMBER,
       cxs_sorts            NUMBER,
       cxs_sharable_mem     NUMBER,
       cxs_address          NUMBER,
       cxs_hashvalue        NUMBER,
       cxs_osuser           VARCHAR2 (30),
       cxs_username         VARCHAR2 (30),
       cxs_module           VARCHAR2 (48),
       cxs_machine          VARCHAR2 (64),
       cxs_status           VARCHAR2 (8),
       cxs_terminal         VARCHAR2 (16),
       cxs_percentconsume   NUMBER,
       cxs_percentrepeat    NUMBER,
       cxs_plan             VARCHAR2 (120)
       );
    
       TYPE plsql_batch IS TABLE OF type_plsql_rec
          INDEX BY BINARY_INTEGER;
          
          
           TYPE type_depend_tab IS RECORD (
          target_name    dba_dependencies.NAME%TYPE,
          refname        dba_dependencies.referenced_name%TYPE,
          reftype        dba_dependencies.referenced_type%TYPE,
          target_owner   dba_dependencies.owner%TYPE,
          refowner       dba_dependencies.referenced_owner%TYPE
       );
    
       TYPE depend_tab IS TABLE OF type_depend_tab
          INDEX BY BINARY_INTEGER;
    Thank you for your time in reading this post

    R

    Johan says:
    Sorry!.
    Actually, I meant

    I thought as well.

    Typos can be expensive however. As a probe of NASA Mars in 99, which was lost due to a simple mathematical error - a confusion between English and metric units. ;-)

    Or screw up a server in reason to use a Unix fork() where the client process think that it is the parent and the beginning more children who believe they are also parents of spawning... (one of my mistakes of kewlest never) :-)

  • Select from 2 dimensions collection returned by a pipeline-table-function

    With the help of 10 gr 2

    A pipeline function returns a collection of an object oriented sub-collection:


    TYPE TXT_ARRAYTYPE IS TABLE OF THE VARCHAR2 (2000);

    type txt2dtable_objtype as object)
    txt2dtable txt_arraytype;

    type txt2dtable_arraytype as the txt2dtable_objtype table;


    FUNCTION getTxtList (start_date IN DATE) RETURN PIPELINED txt2dtable_arraytype
    ....



    How can I select from the function for each element varchar2 grouped by line number (the top-level collection) txt2dtable_arraytype?

    Example:

    Text of RowNum
    1 Hello
    1 World
    2 my
    2 name
    2 is
    2 Nuerni!
    3 How
    ....


    A select statement can be used for an external, OIC - / JDBC / follow App would be great!

    Any ideas?

    Kind regards
    Nuerni

    Something like this:

    SQL>create type txt_arraytype is table of varchar2(2000)
      2  /
    
    Type created.
    
    SQL>create type txt2dtable_objtype as object ( txt2dtable txt_arraytype )
      2  /
    
    Type created.
    
    SQL>create type txt2dtable_arraytype as table of txt2dtable_objtype
      2  /
    
    Type created.
    
    SQL>create or replace FUNCTION getTxtList (start_date in date)
      2  return txt2dtable_arraytype pipelined
      3  is
      4  begin
      5    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'Hello', 'World' ) ) );
      6    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'My', 'name', 'is', 'Anton' ) ) );
      7    pipe row( txt2dtable_objtype( TXT_ARRAYTYPE( 'And', 'this', 'is', 'an', 'example' ) ) );
      8    return;
      9  end;
     10  /
    
    Function created.
    
    SQL>
    SQL>select rn, y.column_value
      2  from ( select rownum rn
      3              , object_value
      4         from table( getTxtList( sysdate ) )
      5       ) x
      6     , table( x.object_value.txt2dtable ) y
      7  /
    
            RN COLUMN_VALUE
    ---------- -----------------------------------------------------------------------------------------
             1 Hello
             1 World
             2 My
             2 name
             2 is
             2 Anton
             3 And
             3 this
             3 is
             3 an
             3 example
    
    11 rows selected.
    
    SQL>
    

    Anton

  • REP-0737: must be a function of return type 'ref cursor.

    Hi all

    I have create a ref cursor query in reports 10 g. But it is giving error REP-0737: must be a function of return type 'ref cursor.

    Here is my code

    function QR_1RefCurDS return sys_refcursor is
    
     My_Cur Sys_Refcursor;
    begin
      Open My_Cur for select * from scott.emp order by deptno;
      return My_Cur
    end;
    

    fate of the screen.

    Ref_Cursor_in_reports10g.jpg

    Oracle Forms/Reports has a complete PL/SQL engine and (only) the SQL parser.

    However, the engine of forms/States PL / SQL and SQL Analyzer are at a level that was in the Oracle 8.0 database.

    So, in the forms/States functions/procedures and forms/States triggers, you can not use SQL commands that did not exist in the 8.0 database.

    The predefined SYS_REFCURSOR type is introduced in Oracle 9i.

    Use this:

    PACKAGE test_rc IS

    TYPE of rc_type IS REF CURSOR RETURN emp % ROWTYPE;

    END;

    FUNCTION RETURN QR_1RefCurDS Test_rc.rc_type IS

    test_rc.rc_type RC;

    BEGIN

    OPEN the RC to SELECT * FROM emp;

    RETURN rc;

    END;

    Kind regards

    Zlatko

  • Property Finder have table as return type

    Hi all

    Is it possible to return the finders of vco table types?

    If I give the property name in the property-bean attribute then it gives [Ljava.lang.String;@4981086 as value (as expected).

    < bean-PROPERTY = display name "testProp" = "Property of Test" hidden = "false" name = "testProp" show in the column = see "real" description = "true" / >

    But is it possible to specify bean-property attribute of tag finder so that we can wrap up the property value according to a static utility method. Maybe something like below (I know that the threshold is not correct, but it's just a wild guess)

    < bean-property = "StringUtils.joinArray (testProp) property' display name ="Test well"hidden ="false"name ="testProp"show in the column = see"real"description ="true"/ >"

    Or any other means by which I can manage property array return types.

    Thank you for your help.

    Best regards

    Sumit Tyagi.

    Hi Sergio,

    Get it now, we can specify any OGNL expression in property accessor of property tag attribute. Read a little on the OGNL expressions and had it work.

    The below xml tag property works for me now.


    Best regards

    Sumit Tyagi

  • Before then, the shift functions return type?

    I can not stress which is the return type of these functions? numeric value or Member?

    And if they come back that a member would be this fomula be valid (I have to take the average of March and June):
    avgppl = @avgrange ("HRsummary"-> "territory", @list (@currmbr ("YearTotal"), @shift (@currmbr ("YearTotal"),-3)))

    Thanks in advance!

    Hello

    All the mentioned functions (Prior, Next, and shift) returns the values and non-members.

    Concerning
    -SM

  • getting this error on the function g 10 isn't a return type

    See the function down
      TYPE ptr IS REF CURSOR;
      FUNCTION check (check_part IN VARCHAR2, check_vendor in varchar2) RETURN ptr;
    FUNCTION check(check_part IN VARCHAR2, check_vendor in varchar2) RETURN ptr is
      
       my_ptr ptr;
        
       check_cnt number(30);
       default_cnt number(30);
          
      BEGIN
        
      select count(*) into check_cnt
      from table_one ps
      where ps.part_number = check_part
      and ps.vendors = check_vendor;
      
      select count(*) into default_cnt 
      from table_one lm 
      where lm.part_number = check_part
      and lm.vendors = 'UNKNOWN';
      
      if (check_cnt = 1 and default_cnt = 0) then
       
        OPEN my_ptr  FOR
        
          SELECT tp.id,
                FROM table_one tp 
          WHERE tp.part_number = (check_part)
          and tp.vendors = (check_vendor);
      return my_ptr;  
        
    elsif (default_cnt = 1 and check_cnt = 0)  then
    
          open my_ptr for 
          
          SELECT tp.id,
           FROM table_one tp 
          WHERE tp.part_number = (check_part)
         and tp.vendors = 'UNKNOWN';
    
    return my_ptr;
    end if;
    
      
    END check;
    Please note that I use oracle 10g all the... Any help is appreciated. Thank you.

    Published by: user13328581 on February 6, 2011 19:36

    sql_dev wrote:
    Hello

    Better just to have a simple statement in the else block

    ELSE
    open my_ptr for
    SELECT NULL
    FROM DUAL;
    return my_ptr;
    

    So whenever the IF fails, your other work without value in the cursor.

    In fact, this slider returns a single row that contains a NULL value.
    Better add a condition that will always evaluate to false (0 = 1).

  • Binding type variable of function return type?

    Hi, is it possible to bind a type variable to a function return type, so that changes in type of variable according to the function return type definition?
    Something like what is happening with TYPE and % ROWTYPE.

    Thank you

    Veverke wrote:
    Hi, is it possible to bind a type variable to a function return type, so that changes in type of variable according to the function return type definition?

    Well, not directly. However, if the function returns SQL declared of type you could:

    1. create a dummy cursor that selects the function of double
    2. create a dummy record variable dummy cursor %
    3. create your variable or dummy record attribute type:

    SQL> desc f1
    FUNCTION f1 RETURNS VARCHAR2
     Argument Name                  Type                    In/Out Default?
     ------------------------------ ----------------------- ------ --------
     P_NUM                          NUMBER                  IN
    
    SQL> declare
      2      desired_variable f1%type;
      3  begin
      4      desired_variable := 1;
      5  end;
      6  /
        desired_variable f1%type;
                         *
    ERROR at line 2:
    ORA-06550: line 2, column 22:
    PLS-00206: %TYPE must be applied to a variable, column, field or attribute, not to "F1"
    ORA-06550: line 2, column 22:
    PL/SQL: Item ignored
    ORA-06550: line 4, column 5:
    PLS-00320: the declaration of the type of this expression is incomplete or malformed
    ORA-06550: line 4, column 5:
    PL/SQL: Statement ignored
    
    SQL> declare
      2      cursor dummy_cursor is select f1(1) f1 from dual;
      3      dummy_record dummy_cursor%rowtype;
      4      desired_variable dummy_record.f1%type;
      5  begin
      6      desired_variable := 1;
      7  end;
      8  /
    
    PL/SQL procedure successfully completed.
    
    SQL>  
    

    SY.

Maybe you are looking for