Oracle: Select From Record Datatype

后端 未结 6 1032

I have a function that returns a record datatype (2 fields: ID and Name). How can I get at the data from a select statement?

Specifically, I am trying using an Oracl

6条回答
  •  情话喂你
    2020-12-10 20:13

    The formatting of my comment for Rob van Wijk is bad. To continue his thought.

    -- create a collection type 
    CREATE TYPE myobj_tab AS TABLE OF myobj; 
    
    -- have the function return a collection type 
    CREATE OR REPLACE function f return myobj_tab 
    IS 
        objtab myobj_tab; 
    BEGIN 
        objtab := myobj_tab(myobj(1,'test')); 
        return objtab; 
    end f; 
    
    -- CAST it as a table and straight up select from it. 
    SELECT id, name FROM TABLE(CAST(f() AS myobj_tab));
    

提交回复
热议问题