How applications can call stored procedures
You can use the SQL CALL statement to call a stored procedure and to pass a list of arguments to that procedure.
An application program can call a stored procedure in the following ways:
- Execute the CALL statement locally, or send the CALL statement to a server. The application executes a CONNECT statement to connect to the server. The application then executes the CALL statement, or it uses a three-part name to identify and implicitly connect to the server where the stored procedure is located.
- After connecting to a server, combine CALL statements with other SQL statements. To execute the CALL statement, you can either execute the CALL statement statically or use an escape clause in an ODBC or JDBC application to pass the CALL statement to Db2.
To execute a stored procedure, you need two types of authorization:
- Authorization to execute the stored procedure
- Authorization to execute the stored procedure package and any packages that are in the stored procedure package
If the owner of the stored procedure has authority to execute the packages, the person who executes the packages does not need the authority.
The authorizations that you need depend on whether the name of the stored procedure is explicitly specified on the CALL statement or is contained in a host variable.
If the stored procedure invokes user-defined functions or triggers, you need additional authorizations to execute the user-defined function, the trigger, and the user-defined function packages.