Procedure

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Post Reply
Marlon Jardel
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 11
Joined: Fri, 23 Jul 2010 10:18 am
Location: Igrejinha RS
Marlon Jardel

Someone can give me a tip.
How do I do to run a procedure within another and return the records of this procedure that was called to the call procedure?


Thanks for the attention.
User avatar
fsitja
Rank: OraSauro
Rank: OraSauro
Posts: 611
Joined: Mon, 19 Jan 2009 4:29 pm
Location: Gaúcho no Rio de Janeiro - RJ
"The scars exist to remind us that the past was real"
Campanha: Como fazer uma pergunta e obter uma resposta.
http://tkyte.blogspot.com/2005/06/how-t ... tions.html

OCA & OCP Developer — OCE SQL Expert — OCS Data Warehousing Specialist

It seems to me that you want something like using Ref cursor as the output parameter of the procedure.

put a little more information about the problem, what you need to solve instead of the solution you thought. Maybe it will give rethinking the solution simplely, looking from another angle.
Marlon Jardel
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 11
Joined: Fri, 23 Jul 2010 10:18 am
Location: Igrejinha RS
Marlon Jardel

The procedure is + or - so.

Select all

create procedure X(p1,p2) 
 variaveis 
begin 
... 
... 
... 
executar procedure_chamada(P1,P2); 
retornar valor; 
 
... 
... 
  
end;
SergioLBJr
Rank: Oracle Guru
Rank: Oracle Guru
Posts: 448
Joined: Tue, 16 Jun 2009 3:07 pm
Location: Parobé - RS
Sérgio Luiz Bonemberger Junior
Programador Junior
Parobé RS

[]s

You just need your call procedure to have a type out parameter.
Dae The field that you pass in this parameter will return what you wish from the procedure.

An example:

Select all

 
create procedure chamada(p1 in number,p2 out boolean) is 
begin 
  if p1 = 1 then 
    p2:= true; 
  else 
    p2 := false; 
  end if; 
end; 
 
Marlon Jardel
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 11
Joined: Fri, 23 Jul 2010 10:18 am
Location: Igrejinha RS
Marlon Jardel

yes, but what is the command I use to call this procedure, I created it with 4 parameters, 3 of them are in (input) and 1 out (output)
I am running it as follows:

Select all

nome_procedure(p1,p2,p3);
These are the input parameters, now I want to play within a variable in another procedure the output parameter. how do I do that.


When calling the procedure the way I put above, it accuses an error:
Incorrect number of argument types in the call to name_procedure.
Marlon Jardel
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 11
Joined: Fri, 23 Jul 2010 10:18 am
Location: Igrejinha RS
Marlon Jardel

Thanks for personal help.
I found another topic in the forum that solved my problem
http://en.glufke.net/oracle/viewtopic.p ... metros+out
When passing the parameters to the procedure, I must inform the input parameters and a variable that You will receive the output value of the procedure.
Ex:

Select all

nome_procedure(entrada1,entrada2,entrada3,variavel_que_recebe_saida) ;

Thanks for the attention of all.
User avatar
gpilger
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 29
Joined: Wed, 21 Apr 2010 3:34 pm
Location: Novo Hamburgo - RS
Gilson Pilger
"Por não saber que erra impossível, ele foi lá e fez" autor desconhecido

To call a procedure within another just declare the internal procedure in the "Declare" section of the PL / SQL block.

Example:

Select all

 
 
create or replace procedure prc_externa (pA in, pB in) is 
 
declare 
   
  -- Minha procedure interna 
  procedure  prc_interna(p1 in, p2 out) is 
 
  begin 
    aqui vai meu código; 
  end prc_interna; 
 
  var_out varchar2(10); 
  
begin 
 
  -- aqui chamo minha proc interna 
  prc_interna('valor 1',var_out);   
 
end prc_externa; 
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 14 guests