Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements >

CREATE PROCEDURE

Use the CREATE PROCEDURE statement to create a user-defined procedure. (To create a procedure from text of source code that is in a separate file, use the CREATE PROCEDURE FROM statement.)

This statement is an extension to the ANSI/ISO standard for SQL.

Syntax

Read syntax diagramSkip visual syntax diagram>>-CREATE--+-----+--PROCEDURE--+-procedure-------+-------------->
           '-DBA-'             |  (1)            |
                               '--------function-'
 
>--(--+---------------------------------+--)-------------------->
      |                            (2)  |
      '-| Routine Parameter List |------'
 
                       (1) (3)
>----| Return Clause |------------------------------------------>
 
>--+--------------------------------------+--------------------->
   |                             (4) (5)  |
   '-SPECIFIC--| Specific Name |----------'
 
>--+---------------------------------------------------------+-->
   |                        .-,-------------------------.    |
   |  (1)    (5)            V                      (6)  |    |
   '---------------WITH--(----| Routine Modifier |------+--)-'
 
>--+---+-------------------------------------------------------->
   '-;-'
 
                         (1) (7)
>--+-| Statement Block |-----------END PROCEDURE--------------------------+-->
   |  (5)    (8)                                  (9)                     |
   '---------------| External Routine Reference |-------+---------------+-'
                                                        '-END PROCEDURE-'
 
>--+---------------------------------------+-------------------->
   |           .-,-----------------------. |
   |           V                   (10)  | |
   '-DOCUMENT----| Quoted String |-------+-'
 
>--+-----------------------------+-----------------------------><
   '-WITH LISTING IN--'pathname'-'
 
Notes:
  1. Stored Procedure Language only
  2. See Routine Parameter List
  3. See Return Clause
  4. See Specific Name
  5. Dynamic Server only
  6. See Routine Modifier
  7. See Statement Block
  8. External routines only
  9. See External Routine Reference
  10. See Quoted String
Element Description Restrictions Syntax
function,
procedure
Name declared here for a new SPL procedure or function (XPS) The name must be unique among all SPL routines in the database. (IDS) See Procedure Names in Dynamic Server. Database Object Name
pathname File to store compile-time warnings Must exist on the computer where the database resides Operating system specific

Usage

The entire length of a CREATE PROCEDURE statement must be less than 64 kilobytes. This length is the literal length of the CREATE PROCEDURE statement, including blank spaces, tabs, and other whitespace characters.

In ESQL/C, you can use CREATE PROCEDURE only as text within a PREPARE statement. If you want to create a procedure for which the text is known at compile time, you must use a CREATE PROCEDURE FROM statement.

Routines use the collating order that was in effect when they were created. See SET COLLATION statement of Dynamic Server for information about using non-default collation.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]