AJUDA COM PROCEDURE TYPE PIPELINED.

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Responder
katiacd
Rank: Programador Pleno
Rank: Programador Pleno
Mensagens: 37
Registrado em: Seg, 09 Mai 2016 3:07 pm
Cristine

Analista Pleno

Pessoal boa noite!

Desenvolvi uma procedure que possui mais de 20 funções. E fiz as devidas chamadas. Porém quero trazer as imformações dos retornos(saida) de cada função em um
type PIPELINED, tem como? Alguém pode me ajudar?

Agradeço muito.

Selecionar tudo

CREATE OR REPLACE PROCEDURE proc_teste
IS
  v_num1  NUMBER;
  v_num2  NUMBER;
  v_num3  NUMBER;
BEGIN
 
  --FUNCTION 1
  v_num1 := FUNCTION1(v_ISS, v_COFINS);

  --FUNCTION 2 
  v_num2 := FUNCTION2(v_IR, v_IMPOSTO);

  --FUNCTION 3 
  v_num3 := FUNCTION3(v_TAXA, v_PERC);
  
  --etc...

END
Avatar do usuário
dr_gori
Moderador
Moderador
Mensagens: 5024
Registrado em: Seg, 03 Mai 2004 3:08 pm
Localização: Portland, OR USA
Contato:
Thomas F. G

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

Acho que nesse post tem muita explicação para o uso de Pipeline functions:

https://blogs.oracle.com/oraclemagazine ... -functions
Veja se ajuda!
A Very Simple Example

Let’s start our exploration of pipelined table functions (which I also refer to as PTFs in this article) by comparing a very simple regular (nonpipelined) table function with a very simple PTF.

First, I create a schema-level nested table type of strings.

Selecionar tudo

CREATE OR REPLACE TYPE strings_t IS TABLE OF VARCHAR2 (100);
/
Next, I compile a table function that returns a nested table of that type with a single string inside it:

Selecionar tudo

CREATE OR REPLACE FUNCTION strings
   RETURN strings_t
   AUTHID DEFINER
IS
   l_strings strings_t := strings_t ('abc');
BEGIN
   RETURN l_strings;
END;
/
When I call the table function in a SELECT statement, it returns abc:

Selecionar tudo

SELECT COLUMN_VALUE my_string FROM TABLE (strings ())
/
MY_STRING
—————————
abc
Now I will create a pipelined version of that same table function.

Selecionar tudo

CREATE OR REPLACE FUNCTION strings_pl
   RETURN strings_t
   PIPELINED
   AUTHID DEFINER
IS
BEGIN
   PIPE ROW ('abc');
   RETURN;
END;
/
And when I run it, I see the same results:

Selecionar tudo

SELECT COLUMN_VALUE my_string FROM TABLE (strings_pl ())
/
MY_STRING
—————————
abc
katiacd
Rank: Programador Pleno
Rank: Programador Pleno
Mensagens: 37
Registrado em: Seg, 09 Mai 2016 3:07 pm
Cristine

Analista Pleno

Boa noite dr_gori!

Obrigada pelo links enviado. Na verdade o que eu preciso, seria um type com retorno dessas funções executadas.. Tipo, o resultado delas , pois será consulta em um front. Esta procedure é de cálculos.

obrigada
katiacd
Rank: Programador Pleno
Rank: Programador Pleno
Mensagens: 37
Registrado em: Seg, 09 Mai 2016 3:07 pm
Cristine

Analista Pleno

Consegui resolver . Deu para fazer como eu esperava. Vou postar o código aqui.
katiacd
Rank: Programador Pleno
Rank: Programador Pleno
Mensagens: 37
Registrado em: Seg, 09 Mai 2016 3:07 pm
Cristine

Analista Pleno

Consegui resolver . Deu para fazer como eu esperava. Estou compartilhando o código aqui.

Selecionar tudo

create or replace PROCEDURE proc_motor ( p_ISS            IN   number,
                                                                  p_COFINS     IN   number,
                                                                  P_IR             IN   number,
                                                                  P_IMPOSTO   IN   number,
                                                                  P_TAXA        IN   number  ) AS
                                         
  --Retorno (Saida Funções Calculadas)                                        
  v_num1  NUMBER := 0;    
  v_num2  NUMBER := 0;
  v_num3  NUMBER := 0;  

  -- type que receberá o retorno (Saida Funções Calculadas)
  type tret_motor is record ( v_num1  number,
                                           v_num2  number,
                                           v_num3  number);
  vretorno tret_motor;                              

  -- função que retorna os valores (Saida Funções Calculadas)
  function fun_ret_motor
  return tret_motor
  is
     vret_motor tret_motor;
  begin

    --Retorno das funções-----------
    --FUNCTION 1
    v_num1 := fn_ISS( p_iss , p_COFINS );

    --FUNCTION 2
    v_num2 := fn_ir( P_IR, P_IMPOSTO);

    --FUNCTION 3
     v_num3 := fn_taxa( P_TAXA, P_IMPOSTO, p_ISS );
     
    --Agora alimentamos o v_row a ser retornado
    vret_motor.v_num1 := v_num1;
    vret_motor.v_num2 := v_num2;
    vret_motor.v_num3 := v_num3;
    --
    return vret_motor;
  end fun_ret_motor;                                                        
  --                      
begin
  -- Chamada da função
  vretorno := fun_ret_motor;
  -- Print dos dados
  dbms_output.put_line('FUNCTION 1: '||vretorno.v_num1);
  dbms_output.put_line('FUNCTION 2: '||vretorno.v_num2);
  dbms_output.put_line('FUNCTION 3: '||vretorno.v_num3);

end;
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 7 visitantes