The SQL CALL statement runs a stored procedure (or, in some dialects, a user-defined function) within the database engine. Procedures encapsulate logic such as data manipulation, calculations, or control-of-flow code. CALL sends control to the procedure, passes any IN parameters, and optionally receives OUT or INOUT parameters and result sets. Because procedures run on the server, they reduce network round-trips, centralize business logic, and allow privileges to be managed in one place. CALL is part of the SQL:1999 standard and is implemented in most enterprise databases, though syntax details (parameter markers, assignment of OUT parameters, multiple result sets) differ by vendor. In interactive sessions it can appear alone; in application code it is typically issued through a client driver that supports parameter binding. When the procedure finishes, execution returns to the caller with any output values set. CALL cannot be used to invoke plain SQL scripts or anonymous blocks; it is strictly for stored objects created with CREATE PROCEDURE (or CREATE FUNCTION where supported).
procedure_name STRING
- The exact name (optionally schema-qualified) of the stored procedure to invoke.argumentN ANY
- One value per formal parameter, passed by position unless the dialect supports named parameters.CREATE PROCEDURE, CREATE FUNCTION, EXEC/EXECUTE, OUT parameter, BEGIN...END, Stored Procedures
SQL:1999
Many databases treat CALL and EXEC/EXECUTE as synonyms, but some (SQL Server) prefer EXEC while others (MySQL, Oracle) standardize on CALL. Always follow your dialect’s convention.
Simply include NULL in the argument list: `CALL update_salary(emp_id => 101, new_salary => NULL);` The procedure must accept NULL or handle it internally.
Yes. A stored procedure can invoke other procedures via CALL, enabling modular design. Ensure you manage transactions and error handling to avoid unintended rollbacks.
Behavior is dialect-specific. MySQL commits implicitly if autocommit is on. PostgreSQL and Oracle leave transaction control to the caller. Always check your database’s transaction model.