INOUT is a parameter mode used in stored procedures and user-defined functions. When a parameter is declared INOUT, the caller passes an initial value (input), the routine can read and change that value, and the final value is written back to the caller (output). INOUT therefore combines the behavior of IN and OUT modes.Key points:- Scope: Only valid inside CREATE FUNCTION and CREATE PROCEDURE statements.- Passing mechanism: Most engines pass INOUT parameters by reference; changes inside the routine are visible after the call completes.- Return type: In PostgreSQL an INOUT parameter also contributes to the routine’s composite result set, so RETURNS can often be omitted. In MySQL and MariaDB, INOUT parameters do not affect the routine’s explicit RETURN value (procedures have none).- NULL handling: If the caller passes NULL, the routine can still assign a non-NULL value before returning.- Privileges: The caller must have EXECUTE permission on the routine and rights to set the variable receiving the output.
param_name identifier
- variable that receives the valueparam_type data type
- any valid scalar or composite typeDEFAULT
(expression) - optional default (PostgreSQL only)Note
- The INOUT keyword itself takes no arguments.#VALUE!
IN parameters, OUT parameters, OUTPUT (SQL Server), RETURNS, CREATE FUNCTION, CREATE PROCEDURE
PostgreSQL 8.1 / MySQL 5.0
IN is read-only input, OUT is write-only output, and INOUT performs both roles so the parameter value can be read and modified.
No. INOUT is valid only within CREATE FUNCTION or CREATE PROCEDURE definitions.
As many as needed, provided the database’s maximum parameter count is not exceeded.
Yes. PostgreSQL treats each INOUT parameter as part of the returned composite row set.