Is it possible to use “return” in stored procedure?

后端 未结 5 1798
情深已故
情深已故 2020-12-06 11:25
 CREATE PROCEDURE Pname(in_Tid IN VARCHAR2,in_IP IN VARCHAR2,outstaticip OUT VARCHAR2,outcount OUT NUMBER)
 AS
 BEGIN
 select STATIC_IP into outstaticip from OP_TTER         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-06 11:57

    -- IN arguments : you get them. You can modify them locally but caller won't see it
    -- IN OUT arguments: initialized by caller, already have a value, you can modify them and the caller will see it
    -- OUT arguments: they're reinitialized by the procedure, the caller will see the final value.
    CREATE PROCEDURE f (p IN NUMBER, x IN OUT NUMBER, y OUT NUMBER)
    IS
    BEGIN
       x:=x * p;
       y:=4 * p;
    END;
    /
    
    SET SERVEROUTPUT ON
    
    declare
       foo number := 30;
       bar number := 0;
    begin
       f(5,foo,bar);
       dbms_output.put_line(foo || ' ' || bar);
    end;
    /
    

    -- Procedure output can be collected from variables x and y (ans1:= x and ans2:=y) will be: 150 and 20 respectively.

    -- Answer borrowed from: https://stackoverflow.com/a/9484228/1661078

提交回复
热议问题