CREATE statements for SQL routines

CREATE statements can be used to create SQL routines and store the routine-body login within the statement.

SQL routines are created by executing the appropriate CREATE statement for the routine type. In the CREATE statement you also specify the routine body, which for an SQL routine must be composed only of SQL or SQL PL statements. You can use the IBM® Db2® Development Center to help you create, debug, and run SQL procedures. SQL procedures, functions, and methods can also be created using the Db2 command line processor.

SQL procedures, functions, and methods each have a respective CREATE statement. Although the syntax for these statements is different, there are some common elements to them. In each you must specify the routine name, and parameters if there are to be any as well as a return type. You can also specify additional keywords that provide Db2 with information about the logic contained in the routine. Db2 uses the routine prototype and the additional keywords to identify the routine at invocation time, and to execute the routine with the required feature support and best performance possible.

For specific information on creating SQL procedures in the Db2 Development Center or from the Command Line Processor, or on creating functions and methods, refer to the related topics.