OUT is a parameter mode defined in the SQL/PSM standard and implemented by most major databases. When a parameter is declared OUT, the called stored procedure or function can assign a value to it, and that value is returned to the caller when execution finishes. The caller must supply a variable, placeholder, or session variable that can receive the output.Key points:- OUT parameters cannot be read inside the routine until they are assigned. They are write-only from the caller’s standpoint.- A routine may declare multiple OUT parameters, allowing it to return several scalar values without building a result set.- OUT differs from INOUT: INOUT lets the caller pass an initial value that the routine can also modify.- In SQL Server the equivalent keyword is OUTPUT, but the concept is identical.- OUT is not available in SQLite and some cloud data warehouses that do not support stored procedures.Caveats:- Forgetting to set an OUT parameter leaves it NULL (or database default), which can cause confusion.- Client libraries differ in how they bind and retrieve OUT parameters; check driver documentation.- OUT parameters are scoped to the call and are not visible across concurrent sessions unless stored in a user session variable.
IN, INOUT, OUTPUT (SQL Server), CREATE PROCEDURE, CREATE FUNCTION, RETURN
SQL:1999 (SQL/PSM)
MySQL, PostgreSQL, Oracle, SQL Server (as OUTPUT), MariaDB, IBM Db2. SQLite does not support them.
Yes. You can declare any number of OUT parameters, separated by commas in the parameter list.
It returns NULL (or database default). Always assign a value to avoid surprises.
RETURN sends a single scalar value from a function, while OUT can send multiple values and is available in both procedures and functions.