I need explanations of OUT and PL / SQL INOUT and Mysql procedure

0

Well, I put PL / SQL and mysql because these two modes have procedures in both Oracle and mysql, but anyway. The IN mode I understood that it works like a constant, it is passed through the parameter and can not be changed inside the procedure .. But I am in doubt in OUT and INOUT mode, I have seen that the out can be changed inside the procedure but it does not "return" a value. What is his functionality then? and the INOUT mode?

    
asked by anonymous 10.07.2018 / 21:07

1 answer

2

According to oracle documentation the out parameters behave like an uninitialized variable, then independent of the value passed in the parameter, the method will receive a null value by default, allowing to change it, returning the value in the variable used. The In Out parameters behave like an initialized variable, the method will receive the value in the parameter and it is possible to change it too, returning the value in the variable used in the parameter. Here is a simple example of the use in oracle:

declare
  Letra CHAR;

  procedure AlteraOut(pLetra out char) is
  begin
    dbms_output.put_line('O valor do parâmetro out é: '||pLetra);
    pLetra := 'B';
  end;

  procedure AlteraInOut(pLetra in out char) is
  begin
    dbms_output.put_line('O valor do parâmetro in out é: '||pLetra);
    pLetra := 'C';
  end; 

begin
  Letra := 'A';

  AlteraOut(Letra);
  dbms_output.put_line('O Valor depois do procedimento out é: '||Letra);

  AlteraInOut(Letra);
  dbms_output.put_line('O Valor depois do procedimento in out é: '||Letra);  
end;

The concept in mysql is the same, as this article

    
11.07.2018 / 14:23