How Db2 determines which stored procedure to run
A procedure is uniquely identified by its name and its qualifying schema name. You can tell Db2 exactly which stored procedure to run by qualifying it with its schema name when you call it. Otherwise, Db2 determines which stored procedure to run.
However, if you do not qualify the stored procedure name, Db2 uses the following method to
determine which stored procedure to run:
- Db2 searches the list of
schema names from the PATH bind option or the CURRENT PATH special
register from left to right until it finds a schema name for which
a stored procedure definition exists with the name in the CALL statement.
Db2 uses schema names from the PATH bind option for CALL statements of the following form:
Db2 uses schema names from the CURRENT PATH special register for CALL statements of the following form:CALL procedure-nameCALL host-variable - When Db2 finds a stored
procedure definition, Db2 executes
that stored procedure if the following conditions are true:
- The caller is authorized to execute the stored procedure.
- The stored procedure has the same number of parameters as in the CALL statement.
- If Db2 cannot find a suitable stored procedure, it returns an SQL error code for the CALL statement.