Como faço para pegar o retorno destes valores desta procedure e inserir em uma tabela. Não conheço muito type,
e não estou conseguindo pegar estes valores retornados.
Veja o exemplo abaixo:
--- Procedure que fica os calculos ---
create or replace NONEDITIONABLE PROCEDURE proc_motor ( t_calculo in out to_calculo) AS
--Retorno (Saida Funções Calculadas)
v_tot_iss NUMBER := 0;
v_tot_ir NUMBER := 0;
-- type que receberá o retorno (Saida Funções Calculadas)
type tret_motor is record ( v_tot_iss number,
v_tot_ir 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_tot_iss := fn_ISS( t_calculo.ISS , t_calculo.COFINS );
--FUNCTION 2
v_tot_ir := fn_ir( t_calculo.IR, t_calculo.IMPOSTO);
--Agora alimentamos o v_row a ser retornado
vret_motor.v_tot_iss := v_tot_iss;
vret_motor.v_tot_ir := v_tot_ir;
--
return vret_motor;
-- END LOOP;
end fun_ret_motor;
begin
-- Chamada da função
vretorno := fun_ret_motor;
-- Print dos dadosfun_ret_motor;
dbms_output.put_line('TOTAL ISS: '||vretorno.v_tot_iss);
dbms_output.put_line('TOTAL IR: '||vretorno.v_tot_ir);
end;
DECLARE
T_CALCULO TO_CALCULO;
BEGIN
PROC_MOTOR(T_CALCULO);
---Insere o resultado da proc na tabela calculo---
INSERT INTO calculo (total_iss,
total_ir)
VALUES(4,
4);
END;
--Resultado do bloco--
TOTAL ISS: 4
TOTAL IR: 4
ISS
obrigada