function return multiple rows?

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Wed, 01 Jun 2005 5:39 pm

I have to make a function that returns multiple rows (equal to a select) to create a report.

Someone have any examples or know where I can find it?
joabel
Location: Chapecó - SC

Poston Thu, 02 Jun 2005 9:53 am

Take a look at these 2 topics: viewtopic.php?t=231 viewtopic.php?t=31
dr_gori
Location: Portland, OR USA

Thomas F. G

Você já respondeu a dúvida de alguém hoje?
http://glufke.net/oracle/search.php?search_id=unanswered

Poston Sat, 04 Jun 2005 8:11 am

I couldn't find a function that returns multiple rows, it's pretty simple.

I'm going to put it because it is simple and can be very useful and some cases.
I hope that helps someone else.

Code: Select all
CREATE OR REPLACE TYPE obj_rel_Tab_preco_row AS OBJECT (
preço      number(16,6), 
comissao   number(5,2) ,
preco_2    number(16,6)
);
/

CREATE OR REPLACE TYPE obj_rel_Tab_preco_table AS TABLE OF obj_rel_Tab_preco_row;
/

create or replace function F_REL_TABELA_PRECO
(
<parametros>
)
  RETURN obj_rel_tab_preco_table AS
  v_tab obj_rel_tab_preco_table := obj_rel_tab_preco_table();
BEGIN
    --
    loop
      --
     .
      .
      .
      --
      v_tab.extend;
      v_tab(v_tab.last) := obj_rel_tab_preco_row( 1, 1.2 ,2 );
      --
      exit when <condicao de saida>
    end loop;
  end if;
  --
  RETURN v_tab;
  -- 
end F_REL_TABELA_PRECO;
joabel
Location: Chapecó - SC


  • See also
    Replies
    Views
    Last Post


    Return to SQL

    Who is online

    Users browsing this forum: No registered users and 2 guests