IBM Support

Displaying definition of stored procedure

Question & Answer


Question

How can I display the definition of an existing stored procedure? 

Answer

The show procedure SQL command displays a summary of all or a specific stored procedure. The summary includes the return type of the procedure, the procedure name, a column indicating if it is user defined or internal, and an arguments list. This command is useful for checking and comparing stored procedure definitions. To see more detailed information, for example if you wish to get the DDL definition for the stored procedure, use the verbose form of the command. 

The following examples illustrate use of both commands on the procedure "my_test." The output of show procedure my_test displays the stored procedure's signature. In the output of the show procedure my_test verbose command, the first part is the stored procedure signature and the second part is the procedure's definition.

system(admin)=> show procedure my_test;
result  | procedure | builtin | arguments
---------+-----------+---------+-----------
boolean | my_test   | f       | ()
(1 row)
 
system(admin)=> show procedure my_test verbose;
result | procedure| builtin| arguments| owner | executedasowner| description | proceduresource
--------+----------+--------+----------+-------+----------------+-------------+-----------
boolean | my_test | f      | ()       | admin | t              |             |
          DECLARE
                  val INT4;
          BEGIN
                  val := 10;
                  RAISE NOTICE 'Original procedures';
                  RETURN TRUE;
          END;

(1 row)

[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

NZ568498

Document Information

Modified date:
17 October 2019

UID

swg21568613