Answers for "oracle function return table"

SQL
4

oracle function return table

CREATE TYPE object_row_type as OBJECT (
  object_type VARCHAR(18),
  object_name VARCHAR(30)
);

CREATE TYPE object_table_type as TABLE OF object_row_type;

CREATE OR REPLACE FUNCTION get_all_objects 
  RETURN object_table_type PIPELINED AS
BEGIN
    FOR cur IN (SELECT * FROM all_objects)
    LOOP
      PIPE ROW(object_row_type(cur.object_type, cur.object_name));   
    END LOOP; 
    RETURN;
END;

SELECT * FROM TABLE(get_all_objects);
Posted by: Guest on August-15-2021
0

plsql function that return a table

create or replace function return_table return t_table as
  v_ret   t_table;
begin

 --
 -- Call constructor to create the returned
 -- variable:
 --
    v_ret  := t_table();

 --
 -- Add one record after another to the returned table.
 -- Note: the »table« must be extended before adding
 -- another record:
 --
    v_ret.extend; v_ret(v_ret.count) := t_record(1, 'one'  );
    v_ret.extend; v_ret(v_ret.count) := t_record(2, 'two'  );
    v_ret.extend; v_ret(v_ret.count) := t_record(3, 'three');

 --
 -- Return the record:
 --
    return v_ret;

end return_table;
/
Posted by: Guest on April-01-2020
0

plsql function that return a table

create or replace type t_record as object (
  i number,
  n varchar2(30)
);
/
Posted by: Guest on April-01-2020

Code answers related to "SQL"

Browse Popular Code Answers by Language