Return TYpe (tablet) as output parameters. [message #678160] |
Wed, 13 November 2019 15:28 |
|
cristine_katia
Messages: 24 Registered: November 2013 Location: SÃO PAULO
|
Junior Member |
|
|
Ret
Good afternoon people!
I have a procedure in Oracle with various functions of calculations, simulator type. So you want to assemble a type with output parameters reading this data and bring the results of these functions in real time, because you want to display as output lines on a front (web screen). I have already created the object and table types. However, I have a hard time assembling because I don't know Type well. Can someone help me? Thanks
|
|
|
|
Re: Return TYpe (tablet) as output parameters. [message #678162 is a reply to message #678161] |
Wed, 13 November 2019 19:53 |
|
cristine_katia
Messages: 24 Registered: November 2013 Location: SÃO PAULO
|
Junior Member |
|
|
Because the mass of data is very large at the time of calculation, so the need for a type, a dynamic form.
Here's a little example of the structure. From there I will play these calculations in type.
Each column refers to the result of a function
CREATE TYPE typ1 AS OBJECT( Valor_Previsto Number,
Valor_simulado Number,
Qtd_simulado Number,
Valor_Iss Number);
[Updated on: Wed, 13 November 2019 19:56] Report message to a moderator
|
|
|
|
Re: Return TYpe (tablet) as output parameters. [message #678186 is a reply to message #678171] |
Thu, 14 November 2019 22:03 |
|
cristine_katia
Messages: 24 Registered: November 2013 Location: SÃO PAULO
|
Junior Member |
|
|
But I do need the type. One for exit and another for entry. My code went like this. It's working, but I need to add a type of parameter input. Does this code have a way to improve or is it good? Follow my code as an example.
thanks
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;
|
|
|
|
|
|