Calling Stored Procedures

A stored procedure is a program that resides on the server. The program can be written by an application developer to accept SQL data via input parameters and to provide SQL data via output parameters. A stored procedure also can return one or more result sets.

Most times, a stored procedure is called from an application program, however, beginning with DB2 v7 for Workstation, stored procedures can be called from the Command Processor. For example:

CALL proc()

This command simply calls a stored procedure named proc which takes no arguments and provides no parameter data back to the caller. The stored procedure can, however, return one or more result sets.

Let's look at a more sophisticated CALL statement.

 CALL empinfo(20000, ...

Get DB2® Universal Database™ v8 Application Development Certification Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.