INOUT
INOUT is a type of parameter mode in SQL stored procedures. This mode enables data to be passed to the procedure and returned back to the calling program. When a variable is declared with INOUT, the calling program can read the updated value of that variable after the procedure ends.
Example
CREATE FUNCTION add_one(INOUT x integer) AS$$BEGIN x := x + 1;END;$$ LANGUAGE plpgsql;SELECT add_one(5);Output
add_one--------- 6(1 row)Explanation
In the example, a function called add_one is created with an INOUT parameter x. The function increases x by 1 each time it is called. When the function is called with 5 as the input, the function returns 6. This is what the Output represents.
Example
CREATE OR REPLACE PROCEDURE sample_inout (param1 IN OUT VARCHAR2) ASBEGINparam1 := 'Output: ' || param1;END;/
DECLAREparam_val VARCHAR2(50) := 'Sample Parameter';BEGINsample_inout(param_val);DBMS_OUTPUT.PUT_LINE(param_val);END;/Output
Output: Sample ParameterExplanation
The example presents a stored procedure sample_inout in Oracle. The procedure accepts an IN OUT parameter, concatenates it with the string ‘Output: ’, and outputs the final value. Upon executing the anonymous block, the given parameter is passed and modified inside the procedure. The output will be ‘Output: Sample Parameter’.