DB2 Server for VSE & VM: Quick Reference


SQL Statements


Invocation

The letters I and P, printed to the right of the statement, indicate where each statement can be used. The I indicates the statement can be issued interactively, and the P indicates the statement can be embedded in an application program.


ACQUIRE DBSPACE (I,P)

Finds and names an available dbspace.

>>-ACQUIRE----+-PUBLIC--+--DBSPACE NAMED--dbspace_name---------->
              '-PRIVATE-'
 
>-----+-------------------------------------------+------------><
      |    .-,-----------------------------.      |
      |    V    (1)                        |      |
      '-(----+--------------------------+--+---)--'
             |             .-8-------.  |
             +-NHEADER = --+-integer-+--+
             |           .-128-----.    |
             +-PAGES = --+-integer-+----+
             |              .-33------. |
             +-PCTINDEX = --+-integer-+-+
             |             .-15------.  |
             +-PCTFREE = --+-integer-+--+
             |          .-PAGE----.     |
             +-LOCK = --+-DBSPACE-+-----+
             |          '-ROW-----'     |
             '-STORPOOL = --integer-----'
 

Notes:

  1. If any of these clauses is specified more than once, the value with the first specification is used.

|ALLOCATE CURSOR (P)

|Defines a cursor and associates it with a result set locator |variable.

|>>-ALLOCATE--cursor-name--CURSOR FOR RESULT SET--rs-locator-variable-->
| 
|>--------------------------------------------------------------><
| 

ALTER DBSPACE (I,P)

Changes the percentage of free space and the type of locking of a PUBLIC dbspace.

>>-ALTER DBSPACE--dbspace_name---------------------------------->
 
        .-,--------------------------------.
        V   (1)                            |
>----(------------+-PCTFREE = integer---+--+---)---------------><
                  '-LOCK =--+-PAGE----+-'
                            +-DBSPACE-+
                            '-ROW-----'
 

Notes:

  1. If either of these clauses is specified more than once, the value with the first specification is used.

ALTER PROCEDURE (I,P)

Alters the definition of a stored procedure.

ALTER PROCEDURE
 
>>-ALTER PROCEDURE---procedure-name----+-----------------+------>
                                       '-AUTHID--authid--'
 
      .-,-----------------.
      V                   |  (1)
>--------+-------------+--+------------------------------------><
         '-| options |-'
 

Notes:

  1. One or more clauses may be specified, however each clause may be specified at most once.

 
options
 
|--+-LANGUAGE-+-ASSEMBLE-+---------------------------------+----|
   |          +-C--------+                                 |
   |          +-COBOL----+                                 |
   |          '-PLI------'                                 |
   +-EXTERNAL NAME--external-program-name------------------+
   +-SERVER GROUP--+-------------------+-------------------+
   |               '-server-group-name-'                   |
   +-+-DEFAULT SERVER GROUP YES-+--------------------------+
   | '-DEFAULT SERVER GROUP NO--'                          |
   |                                   (2)                 |
   +---+-----------------+---+-GENERAL-----------------+---+
   |   '-PARAMETER STYLE-'   |                    (3)  |   |
   |                         '-GENERAL WITH NULLS------'   |
   +---STAY RESIDENT-+-NO--+-------------------------------+
   |                 '-YES-'                               |
   +-+-PROGRAM TYPE MAIN-----+-----------------------------+
   | |                  (4)  |                             |
   | '-PROGRAM TYPE SUB------'                             |
   +-RUN OPTIONS--run-time-options-------------------------+
   +-RESULT--+-SET--+---integer----------------------------+
   |         '-SETS-'                                      |
   +-COMMIT ON RETURN-+-NO--+------------------------------+
   |                  '-YES-'                              |
   |                     (1)  (5)                          |
   +-+-NOT DETERMINISTIC-----------+-----------------------+
   | |               (1)  (6)      |                       |
   | '-DETERMINISTIC---------------'                       |
   |                (1)                                    |
   +-+-CONTAINS SQL-----------+----------------------------+
   | |        (1)             |                            |
   | +-NO SQL-----------------+                            |
   | |                (1)     |                            |
   | +-READS SQL DATA---------+                            |
   | |                   (1)  |                            |
   | '-MODIFIES SQL DATA------'                            |
   |             (1)                                       |
   +-+-NO COLLID-------------------+-----------------------+
   | |                       (1)   |                       |
   | '-COLLID--collection-id-------'                       |
   |                   (1)                                 |
   +-+-WLM ENVIRONMENT------+-name-----+-+-----------------+
   | |                      '-(name,*)-' |                 |
   | |                    (1)            |                 |
   | '-NO WLM ENVIRONMENT----------------'                 |
   |         (1)                                           |
   +-ASUTIME-------+-NO LIMIT--------+---------------------+
   |               '-LIMIT--integer--'                     |
   |    (1)                                                |
   +-+-------------------------------+---------------------+
   | '-EXTERNAL SECURITY-+-DB2-----+-'                     |
   |                     +-USER----+                       |
   |                     '-DEFINER-'                       |
   |             (1)                                       |
   '-+-NO DBINFO------+------------------------------------'
     |        (1)     |
     '-DBINFO---------'
 

Notes:

  1. This parameter is included for compatibility with the DB2 family. If specified, it is ignored.

  2. SIMPLE CALL may be used as an alternative to GENERAL. This is for compatibility within the DB2 family.

  3. SIMPLE CALL WITH NULLS may be used as an alternative to GENERAL WITH NULLS. This is for compatibility within the DB2 family.

  4. Currently, DB2 Server for VSE & VM supports stored procedures written as main programs only.

  5. VARIANT may be specified as an alternative to NOT DETERMINISTIC. This is for compatibility within the DB2 family.

  6. NOT VARIANT may be specified as an alternative to DETERMINISTIC. This is for compatibility within the DB2 family.

ALTER PSERVER (I,P)

Alters the definition of a stored procedure server.

>>-ALTER PSERVER------------------------------------------------>
 
                        .-,------------------------------.
                        V    (1)                         |
>-----procedure-server----+---------------------------+--+-----><
                          +-GROUP--+------------+-----+
                          |        '-group-name-'     |
                          +-+-AUTOSTART NO--+---------+
                          | '-AUTOSTART YES-'         |
                          '-DESCRIPTION--description--'
 

Notes:

  1. One or more clauses may be specified, however each clause may be specified at most once.

ALTER TABLE (I,P)

Adds a new column, or adds, drops, activates, or deactivates a primary key, foreign key, or unique constraint on a specified table.

>>-ALTER TABLE--table_name-------------------------------------->
 
>-----+-ADD--| column-definition-block |--------------+--------><
      | .-ADD-.                                       |
      +-+-----+--+-| primary-key-block |------------+-+
      |          +-| referential-constraint-block |-+ |
      |          '-| unique-block |-----------------' |
      +-DROP--+-PRIMARY KEY-------------------+-------+
      |       +-FOREIGN KEY--constraint_name--+       |
      |       '-UNIQUE--constraint_name-------'       |
      +-ACTIVATE--+-ALL---------------------------+---+
      |           +-PRIMARY KEY-------------------+   |
      |           +-FOREIGN KEY--constraint_name--+   |
      |           '-UNIQUE--constraint_name-------'   |
      +-DEACTIVATE--+-ALL---------------------------+-+
      |             +-PRIMARY KEY-------------------+ |
      |             +-FOREIGN KEY--constraint_name--+ |
      |             '-UNIQUE--constraint_name-------' |
      '-DATA CAPTURE--+-NONE----+---------------------'
                      '-CHANGES-'
 

 
column-definition-block
 
|--column_name-------------------------------------------------->
 
>-----| data-type |--+-----------------------------+------------|
                     |  (1)                        |
                     '--------| fieldproc-block |--'
 
data-type
 
|---+-INTeger--------------------------------------------------+->
    +-SMALLINT-------------------------------------------------+
    |          .-(53)------.                                   |
    +-+-FLOAT--+-----------+-+---------------------------------+
    | |        '-(integer)-' |                                 |
    | +-REAL-----------------+                                 |
    | '-DOUBLE PRECISION-----'                                 |
    |                .-(5,0)------------------------.          |
    +--+-DECimal-+---+------------------------------+----------+
    |  '-NUMERIC-'   '-(--integer--+----------+--)--'          |
    |                              '-,integer-'                |
    |               .-(1)-------.                              |
    +--+-CHARacter--+-----------+-+---+-----------------+------+
    |  |            '-(integer)-' |   |  (1)            |      |
    |  +-VARCHAR--(integer)-------+   +-----------------+      |
    |  '-LONG VARCHAR-------------'   +-FOR SBCS DATA---+      |
    |                                 +-FOR MIXED DATA--+      |
    |                                 +-FOR BIT DATA----+      |
    |                                 '-CCSID--integer--'      |
    |             .-(1)-------.                                |
    +--+-GRAPHIC--+-----------+-+---+------------------------+-+
    |  |          '-(integer)-' |   |  (1)                   | |
    |  +-VARGRAPHIC--(integer)--+   '--------CCSID--integer--' |
    |  '-LONG VARGRAPHIC--------'                              |
    |                                                          |
    +-DATE-----------------------------------------------------+
    +-TIME-----------------------------------------------------+
    '-TIMESTAMP------------------------------------------------'
 
>---------------------------------------------------------------|
 

Notes:

  1. These clauses may be specified in any order.

|ASSOCIATE LOCATORS (P)

|Obtains the RESULT SET LOCATOR value for each result set data type |returned by a stored procedure.

|>>-ASSOCIATE----+----------------+---+-LOCATOR-------+---------->
|                '-| RESULT SET |-'   |          (1)  |
|                                     '-LOCATORS------'
| 
|         .-,----------------------.
|         V                        |
|>-----(-----rs-locator-variable---+---)---WITH PROCEDURE-------->
| 
|>-----+-host-variable--+---------------------------------------><
|      '-procedure-name-'
| 

|Notes:

  1. |RESULT SET LOCATOR variables are only supported in client applications |written in Assembler, C, COBOL, and PL/I. |

BEGIN DECLARE SECTION (P)

Marks the beginning of a host variable declare section, including host structures.

>>-BEGIN DECLARE SECTION---------------------------------------><
 

CALL (P)

Invokes a stored procedure with a list of input/output parameters.

>>-CALL----+-procedure-name-+----------------------------------->
           '-host-variable--'
 
>-----+-------------------------------------+------------------><
      +-(--+-------------------------+---)--+
      |    |  .-,------------------. |      |
      |    |  V                    | |      |
      |    '----+-host-variable-+--+-'      |
      |         +-constant------+           |
      |         '-NULL----------'           |
      '-USING DESCRIPTOR--descriptor-name---'
 

CLOSE (P)

Closes the cursor identified by cursor-name.

>>-CLOSE--cursor_name------------------------------------------><
 

Extended CLOSE (P)

Closes the cursor identified by cursor-variable.

>>-CLOSE--cursor_variable--------------------------------------><
 

COMMENT ON (I,P)

Adds or replaces comments in the catalog descriptions of tables, views, or columns.

>>-COMMENT ON--------------------------------------------------->
 
>-----+--| options_a |------------------------IS--str_constant----+>
      |                      .-,--------------------------------.     |
      |                      V                                  |     |
      '--+-table_name-+---(-----column_name--IS--str_constant---+---)-'
         '-view_name--'
 
>--------------------------------------------------------------><
 
options_a
 
|--+-TABLE--+-table_name-+--------------+-----------------------|
   |        '-view_name--'              |
   '-COLUMN--+-table_name.column_name-+-'
             '-view_name.column_name--'
 

COMMENT ON PROCEDURE (I,P)

Adds or replaces comments in the catalog descriptions of stored procedures.

>>-COMMENT ON PROCEDURE--procedure_name----+------------------+->
                                           '-AUTHID--authid---'
 
>----IS--string_constant---------------------------------------><
 

COMMIT (I,P)

Ends the current logical unit of work and commits any changes.

           .-WORK-.
>>-COMMIT--+------+--+---------+-------------------------------><
                     '-RELEASE-'
 

CONNECT (I,P)

Connects an application process or a user, or both, to an application server.

>>-CONNECT------------------------------------------------------>
 
>-----+--------------------------------------------------------------+>
      '--+-authorization_name-+--IDENTIFIED BY----+-password------+--'
         '-host_variable------'                   '-host_variable-'
 
>-----+------------------------+-------------------------------><
      '-TO--+-server_name---+--'
            '-host_variable-'
 

CREATE INDEX (I,P)

Creates an index on one or more columns of a table.

>>-CREATE--+--------+--INDEX--index_name-----------------------><
           '-UNIQUE-'
 

                        .-,-----------------------.
                        V               .-ASC--.  |
>>-ON--table_name--(-------column_name--+------+--+--)---------><
                                        '-DESC-'
 

   .-PCTFREE=10------.
>>-+-----------------+-----------------------------------------><
   '-PCTFREE=integer-'
 

CREATE PACKAGE (P)

Creates a package.

                   (1)
>>-CREATE PACKAGE----------------------------------------------->
 
>----package_spec--+------------------------------------------+-><
                   |                   .-----------------.    |
                   |                   V  (2)            |    |
                   '-USING OPTIONs--+-----------option---+-+--'
                                    '-host_variable--------'
 

Notes:

  1. PROGRAM is equivalent to PACKAGE, and is provided for compatibility with some older versions of the SQL/DS product.

  2. An option may be specified only once.

Using Options


Table 1.  
CCSIDSbcs (integer) NOCHECK | CHECK | ERROR
CCSIDMixed (integer) NODESCRIBE | DESCRIBE
CCSIDGraphic (integer) NOEXIST | EXIST
CHARSUB (Sbcs | Mixed | Bit) NOMODIFY | MODIFY
DATE (ISO | USA | EUR | JIS |      LOCAL) OWner (authorization-name)
EXPLAIN (NO | YES) QUALifier (collection-id)
ISOLation (RR | RS | CS | UR |      USER) RELease (COMMIT | DEALLOCATE)
KEEP | REVOKE REPLACE | NEW
LABEL (label-text) TIME (ISO | USA | EUR | JIS |      LOCAL)
NOBLock | BLock | SBLock  


CREATE PROCEDURE (I,P)

Defines a stored procedure.

>>-CREATE PROCEDURE---procedure-name----+-----------------+--(-->
                                        '-AUTHID--authid--'
 
>-----+----------------+--)------------------------------------->
      '-| parameters |-'
 
      .-,------------------------------------------------------.
      |              (1)                                       |
      V     .-FENCED------------------------------------.      |  (8)
>---------+-+-------------------------------------------+-+----+----->
          | +-LANGUAGE-+-ASSEMBLE-+---------------------+ |
          | |          +-C--------+                     | |
          | |          +-COBOL----+                     | |
          | |          '-PLI------'                     | |
          | +-EXTERNAL-+------------------------------+-+ |
          | |          '-NAME--external-program-name--' | |
          | +-SERVER GROUP--+-------------------+-------+ |
          | |               '-server-group-name-'       | |
          | | .-DEFAULT SERVER GROUP YES--.             | |
          | +-+---------------------------+-------------+ |
          | | '-DEFAULT SERVER GROUP NO---'             | |
          | '-+------------------------------+----------' |
          |   +-PARAMETER STYLE--------------+            |
          |   |                      (3)     |            |
          |   | .-GENERAL WITH NULLS-------. |            |
          |   |-|         (2)              | |            |
          |   '-+-GENERAL------------------+-'            |
          | .-STAY RESIDENT NO--.                         |
          +-+-------------------+-------------------------+
          | '-STAY RESIDENT YES-'                         |
          | .-PROGRAM TYPE MAIN-----.                     |
          +-+-----------------------+---------------------+
          | |                  (4)  |                     |
          | '-PROGRAM TYPE SUB------'                     |
          +-+--------------------------------+------------+
          | '-RUN OPTIONS--run-time-options--'            |
          | .-RESULT SET 0-------------.                  |
          +-+--------------------------+------------------+
          | '-RESULT-+-SET--+--integer-'                  |
          |          '-SETS-'                             |
          | .-COMMIT ON RETURN NO--.                      |
          +-+----------------------+----------------------+
          | '-COMMIT ON RETURN YES-'                      |
          |                     (5)                       |
          | .-NOT DETERMINISTIC-------.                   |
          +-+-------------------------+-------------------+
          | |               (6)       |                   |
          | '-DETERMINISTIC-----------'                   |
          |                (7)                            |
          | .-CONTAINS SQL-----------.                    |
          +-+------------------------+--------------------+
          | |        (7)             |                    |
          | +-NO SQL-----------------+                    |
          | |                (7)     |                    |
          | +-READS SQL DATA---------+                    |
          | |                   (7)  |                    |
          | '-MODIFIES SQL DATA------'                    |
          |             (7)                               |
          | .-NO COLLID-------------------.               |
          +-+-----------------------------+---------------+
          | |                       (7)   |               |
          | '-COLLID--collection-id-------'               |
          +-+-----------------------------------+---------+
          | |                 (7)               |         |
          | +-WLM ENVIRONMENT------+-name-----+-+         |
          | |                      '-(name,*)-' |         |
          | |                    (7)            |         |
          | '-NO WLM ENVIRONMENT----------------'         |
          |                    (7)                        |
          | .-ASUTIME NO LIMIT-------------.              |
          +-+------------------------------+--------------+
          | |                        (7)   |              |
          | '-ASUTIME LIMIT--integer-------'              |
          |                         (7)                   |
          | .-EXTERNAL SECURITY DB2--------------.        |
          +-+------------------------------------+--------+
          | |                   (7)              |        |
          | '-EXTERNAL SECURITY------+-USER----+-'        |
          |                          '-DEFINER-'          |
          |             (7)                               |
          | .-NO DBINFO-------.                           |
          '-+-----------------+---------------------------'
            |        (7)      |
            '-DBINFO----------'
 
>--------------------------------------------------------------><
 

Notes:

  1. This parameter is included for compatibility with the DB2 family. If specified, it is ignored.

  2. As an alternative to GENERAL, SIMPLE CALL may be used. This is for compatibility within the DB2 family.

  3. As an alternative to GENERAL WITH NULLS, SIMPLE CALL WITH NULLS may be used. This is for compatibility within the DB2 family.

  4. Currently, DB2 Server for VSE & VM supports stored procedures written as main programs only.

  5. VARIANT may be specified as an alternative to NOT DETERMINISTIC. This is for compatibility within the DB2 family.

  6. NOT VARIANT may be specified as an alternative to DETERMINISTIC. This is for compatibility within the DB2 family.

  7. This parameter is included for compatibility with the DB2 family. If specified, it is ignored.

  8. One or more clauses may be specified, however each clause may be specified at most once.

 
parameters
 
   .-,-------------------------------------------------------------------.
   V  .-IN----.                                                          |
|-----+-------+---+----------------+--| data-type |-+-----------------+--+->
      +-OUT---+   '-parameter-name-'                |            (1)  |
      '-INOUT-'                                     '-AS LOCATOR------'
 
>---------------------------------------------------------------|
 
data-type
 
|---+-INT---------------------------------------------------------+->
    +-INTEGER-----------------------------------------------------+
    +-SMALLINT----------------------------------------------------+
    +-REAL--------------------------------------------------------+
    +-FLOAT-------------------------------------------------------+
    +-DOUBLE------------------------------------------------------+
    +-DOUBLE PRECISION--------------------------------------------+
    +--+-DECIMAL-+---+-------------------------------+------------+
    |  '-DEC-----'   '-(--integer--+----------+---)--'            |
    |                              '-,integer-'                   |
    +--+-CHARACTER-+---+-----------+---+------------------------+-+
    |  '-CHAR------'   '-(integer)-'   '-FOR--+-SBCS--+---DATA--' |
    |                                         +-MIXED-+           |
    |                                         '-BIT---'           |
    +-VARCHAR(integer)---+------------------------+---------------+
    |                    '-FOR--+-SBCS--+---DATA--'               |
    |                           +-MIXED-+                         |
    |                           '-BIT---'                         |
    +-GRAPHIC(integer)--------------------------------------------+
    '-VARGRAPHIC(integer)-----------------------------------------'
 
>---------------------------------------------------------------|
 

Notes:

  1. This parameter is included for compatibility with the DB2 family. If specified, it is ignored.

CREATE PSERVER (I,P)

Defines a stored procedure server.

                                     .-,-------------------------------.
                                     V                                 |
>>-CREATE PSERVER--procedure-server-----+---------------------------+--+->
                                        |  (1)                      |
                                        +---------------------------+
                                        +-GROUP--group-name---------+
                                        | .-AUTOSTART NO--.         |
                                        +-+---------------+---------+
                                        | '-AUTOSTART YES-'         |
                                        '-DESCRIPTION--description--'
 
>--------------------------------------------------------------><
 

Notes:

  1. One or more clauses may be specified, however each clause may be specified at most once.

CREATE SYNONYM (I,P)

Defines an alternative name for a table or view.

>>-CREATE SYNONYM--synonym--FOR----+-qualified_table_name-+----><
                                   '-qualified_view_name--'
 

CREATE TABLE (I,P)

Creates a new table.

>>-CREATE TABLE--table_name------------------------------------->
 
        .-,---------------------------------------------.
        V   (1)                                         |
>----(------------+-| column-definition-block |------+--+---)--->
                  |                       (2)        |
                  +-| primary-key-block |------------+
                  +-| referential-constraint-block |-+
                  '-| unique-block |-----------------'
 
      .-----------------------------------.
      V                                   |
>--------+-----------------------------+--+--------------------><
         +-IN--dbspace_name------------+
         |                      (3)    |
         '-DATA CAPTURE--+-NONE------+-'
                         '-CHANGES---'
 

Notes:

  1. There can be up to 255 columns in a table.

  2. Only one primary key may be defined (either in a primary-key-block or as a column attribute).

  3. The same clause must not be specified more than once.

 

 
column-definition-block
 
|--column_name-------------------------------------------------->
 
>-----+-INTeger--------------------------------------------------+>
      +-SMALLINT-------------------------------------------------+
      |          .-(53)------.                                   |
      +-+-FLOAT--+-----------+-+---------------------------------+
      | |        '-(integer)-' |                                 |
      | +-REAL-----------------+                                 |
      | '-DOUBLE PRECISION-----'                                 |
      |                .-(5,0)------------------------.          |
      +--+-DECimal-+---+------------------------------+----------+
      |  '-NUMERIC-'   '-(--integer--+----------+--)--'          |
      |                              '-,integer-'                |
      |               .-(1)-------.                              |
      +--+-CHARacter--+-----------+-+---+-----------------+------+
      |  |            '-(integer)-' |   |  (1)            |      |
      |  +-VARCHAR--(integer)-------+   +-----------------+      |
      |  '-LONG VARCHAR-------------'   +-FOR SBCS DATA---+      |
      |                                 +-FOR MIXED DATA--+      |
      |                                 +-FOR BIT DATA----+      |
      |                                 '-CCSID--integer--'      |
      |             .-(1)-------.                          (1)   |
      +--+-GRAPHIC--+-----------+-+---+-----------------+--------+
      |  |          '-(integer)-' |   '-CCSID--integer--'        |
      |  +-VARGRAPHIC--(integer)--+                              |
      |  '-LONG VARGRAPHIC--------'                              |
      +-DATE-----------------------------------------------------+
      +-TIME-----------------------------------------------------+
      '-TIMESTAMP------------------------------------------------'
 
                                            (1)
>-----+---------------------------------+----------------------->
      '-NOT NULL--+------------------+--'
                  +-UNIQUE-----------+
                  |             (2)  |
                  '-PRIMARY KEY------'
 
                           (1)
>------| fieldproc-block |--------------------------------------|
 

Notes:

  1. These clauses may be specified in any order.

  2. Only one primary key may be defined (either in a primary-key-block or as a column attribute).

 
 
fieldproc-block
 
|--FIELDPROC--program_name----+-------------------------+-------|
                              |    .-,-----------.      |
                              |    V             |      |
                              '-(-----constant---+---)--'
 
 
 
primary-key-block
 
                     .-,------------------------------.
                     V   (1)                .-ASC--.  |
|--PRIMARY KEY--(--------------column_name--+------+--+--)------>
                                            '-DESC-'
 
      .-PCTFREE = 10----.
>-----+-----------------+---------------------------------------|
      '-PCTFREE=integer-'
 

Notes:

  1. A PRIMARY KEY can have up to 16 columns.

 
 
referential-constraint-block
 
                                          .-,--------------.
                                          V                |
|--FOREIGN KEY--+-----------------+--(-------column_name---+---->
                '-constraint_name-'
 
>----)--REFERENCES--table_name----+---------------------------+-|
                                  |            .-RESTRICT--.  |
                                  '-ON DELETE--+-CASCADE---+--'
                                               '-SET NULL--'
 
 
 
unique-block
 
|--UNIQUE--+-----------------+---------------------------------->
           '-constraint_name-'
 
        .-,------------------------------.
        V   (1)                .-ASC--.  |
>----(------------column_name--+------+--+---)------------------>
                               '-DESC-'
 
      .-PCTFREE=10------.
>-----+-----------------+---------------------------------------|
      '-PCTFREE=integer-'
 

Notes:

  1. There can be up to 16 columns on a unique constraint.

CREATE VIEW (I,P)

Creates a view on one or more tables or views.

>>-CREATE VIEW--view_name----+----------------------------+----->
                             |    .-,--------------.      |
                             |    V                |      |
                             '-(-----column_name---+---)--'
 
>----AS--subselect--+-------------------+----------------------><
                    '-WITH CHECK OPTION-'
 

DECLARE CURSOR (P)

Declares the cursor that you can use to fetch or put the results of a prepared statement.

>>-DECLARE---cursor-name---CURSOR----+----------------+--FOR---->
                                     +-WITH RETURN----+
                                     |           (1)  |
                                     '-WITH HOLD------'
 
>-----+-select-statement-+-------------------------------------><
      '-statement-name---'
 

Notes:

  1. Note that DB2 Server for VSE & VM does not support CURSOR WITH HOLD.

Extended DECLARE CURSOR (P)

Declares the cursor that you can use to fetch or put the results of a prepared statement.

>>-DECLARE--cursor_variable---CURSOR FOR--section_variable------>
 
>----IN--package_spec------------------------------------------><
 

DELETE (I,P)

Deletes one or more rows from a table or view. Deleting a row from a view deletes the row from the table on which the view is based.

Searched delete (I,P)

>>-DELETE FROM----+-table_name-+--+------------------+---------><
                  '-view_name--'  '-correlation_name-'
 
>>-+--------------------------+---+---------------+------------><
   '-WHERE--search_condition--'   '-WITH--+-RR-+--'
                                          '-CS-'
 

Positioned delete (P)

>>-DELETE FROM----+-table_name-+-------------------------------->
                  '-view_name--'
 
                      (1)
>----WHERE CURRENT OF-------cursor_name------------------------><
 

Notes:

  1. A Positioned DELETE in FORTRAN, and programs prepared using Extended dynamic SQL cannot be used with DRDA protocol.

DESCRIBE (P)

Retrieves information about an SQL select-statement previously prepared with a PREPARE statement.

>>-DESCRIBE--statement_name--INTO--descriptor_name-------------->
 
>-----+-------------------+------------------------------------><
      |        .-NAMES--. |
      '-USING--+-ANY----+-'
               +-BOTH---+
               '-LABELS-'
 

Extended DESCRIBE (P)

Retrieves information about an SQL SELECT statement previously prepared with an Extended PREPARE statement.

>>-DESCRIBE--statement_variable--IN--package_spec--------------->
 
>----INTO--descriptor_name--+-------------------+--------------><
                            |        .-NAMES--. |
                            '-USING--+-ANY----+-'
                                     +-BOTH---+
                                     '-LABELS-'
 

|DESCRIBE CURSOR (P)

|Obtains information about the result set that is associated with the |cursor and puts that information into a descriptor.

|>>-DESCRIBE CURSOR--+-cursor-name---+---INTO--descriptor-name--><
|                    '-host-variable-'
| 

|DESCRIBE PROCEDURE (P)

|Obtains information about the result sets returned by a stored |procedure and puts that information into a descriptor.

|>>-DESCRIBE PROCEDURE--+-host-variable--+---INTO--descriptor-name-->
|                       '-procedure-name-'
| 
|>--------------------------------------------------------------><
| 

DROP (I,P)

Deletes an object. Objects that are directly or indirectly dependent on that object are also deleted.

>>-DROP----+-DBSPACE--dbspace_name------------+----------------><
           +-INDEX--index_name----------------+
           |         (1)  (2)                 |
           +-PACKAGE------------package_spec--+
           +-SYNONYM--synonym-----------------+
           +-TABLE--table_name----------------+
           '-VIEW--view_name------------------'
 

Notes:

  1. PROGRAM is equivalent to PACKAGE and is provided for compatibility with prior releases of SQL/DS.

  2. DROP PACKAGE cannot support a qualified structure subfield name. A host structure subfield name can be used as normal host variables, but must be unqualified. If being unqualified results in an ambiguous reference, the subfield cannot be used.

DROP PROCEDURE (I,P)

Removes a stored procedure.

>>-DROP PROCEDURE---procedure-name----+-----------------+------->
                                      '-AUTHID--authid--'
 
>-----+----------+---------------------------------------------><
      '-RESTRICT-'
 

DROP PSERVER (I,P)

Removes a stored procedure pserver.

>>-DROP PSERVER---procedure-server-----------------------------><
 

DROP STATEMENT (P)

Selectively deletes a statement from a package.

>>-DROP STATEMENT--section_variable--IN--package_spec----------><
 

END DECLARE SECTION (P)

Marks the end of a host-variable declare section.

>>-END DECLARE SECTION-----------------------------------------><
 

EXECUTE (P)

Executes a prepared SQL statement.

>>-EXECUTE--statement_name-------------------------------------->
 
>-----+------------------------------------+-------------------><
      +-USING--host_variable_list----------+
      '-USING DESCRIPTOR--descriptor_name--'
 

Extended EXECUTE (P)

Executes a statement previously prepared by an Extended PREPARE statement.

>>-EXECUTE--section_variable--IN--package_spec------------------>
 
>-----+--------------------------------------+------------------>
      '-USING DESCRIPTOR--descriptor_name_1--'
 
>-----+---------------------------------------------+----------><
      '-USING OUTPUT DESCRIPTOR--descriptor_name_2--'
 

EXECUTE IMMEDIATE (P)

Prepares an executable form of an SQL statement from a character string form of the statement, executes the SQL statement, and then destroys the executable form.

>>-EXECUTE IMMEDIATE----+-string_constant-+--------------------><
                        '-host_variable---'
 

EXPLAIN (I,P)

Retrieves information about the access path chosen for the execution of the SQL query, and about the structure and execution performance of a DELETE, INSERT, UPDATE or select-statement.

>>-EXPLAIN----+-ALL-----------------+--------------------------->
              |  .-,--------------. |
              |  V                | |
              '----+-COST------+--+-'
                   +-PLAN------+
                   +-REFERENCE-+
                   '-STRUCTURE-'
 
>-----+-----------------------------------+--------------------->
      |                        (1)  (2)   |
      '-SET QUERYNO =--integer------------'
 
>----FOR--explainable_sql_statement----------------------------><
 

Notes:

  1. The QUERYNO can be up to 2,147,483,647.

  2. The integer constant must not be preceded by a sign.

FETCH (P)

Positions a cursor on the next row of its result table and assigns the values of that row to the host variables.

>>-FETCH--cursor_name----+-INTO--host_variable_list-----------+-><
                         '-USING DESCRIPTOR--descriptor_name--'
 

Extended FETCH (P)

Positions a cursor on the next row of its result table and assigns the values of that row to the host variables.

>>-FETCH--cursor_variable---USING DESCRIPTOR--descriptor_name--><
 

GRANT Package Privileges (I,P)

Grants the privilege to execute a package.

                     (1)
>>-GRANT EXECUTE ON--------package_name------------------------->
 
         .-,-----------------------.
         V                         |
>----TO----+-authorization_name-+--+--+-------------------+----><
           '-PUBLIC-------------'     '-WITH GRANT OPTION-'
 

Notes:

  1. RUN can be specified as a synonym for EXECUTE to support applications developed for previous releases of SQL/DS.

GRANT System Authorities (I,P)

Grants authorities to users and changes passwords.

>>-GRANT-------------------------------------------------------->
 
>-----+--+-CONNECT--+--TO----| AUTH |--+--------+----------+---><
      |  +-DBA------+                  '-| ID |-'          |
      |  '-RESOURCE-'                                      |
      |             .-,-----------------------.            |
      |             V                         |            |
      +-CONNECT TO----+-authorization_name-+--+------------+
      |               |          (1)       |               |
      |               '-ALLUSERS-----------'               |
      '-SCHEDULE TO--subsystemid--IDENTIFIED BY--password--'
 
AUTH
 
    .-,---------------------.
    V                       |
|------authorization_name---+-----------------------------------|
 
ID
 
                   .-,-----------.
                   V             |
|---IDENTIFIED BY-----password---+------------------------------|
 

Notes:

  1. ALLUSERS can only be specified once and is not applicable to a VSE application server.

GRANT Table Privileges (I,P)

Grants privileges on a table or view.

>>-GRANT-------------------------------------------------------->
 
             .-PRIVILEGES-.
>-----+-ALL--+------------+------------------------------+------>
      |  .-,-------------------------------------------. |
      |  V         (1)                                 | |
      '----+-ALTER----------------------------------+--+-'
           +-DELETE---------------------------------+
           |       (1)                              |
           +-INDEX----------------------------------+
           +-INSERT---------------------------------+
           |            (1)                         |
           +-REFERENCES-----------------------------+
           +-SELECT---------------------------------+
           '-UPDATE--+----------------------------+-'
                     |    .-,--------------.      |
                     |    V                |      |
                     '-(-----column_name---+---)--'
 
                              .-,-----------------------.
                              V                         |
>----ON--+-table_name-+---TO----+-authorization_name-+--+------->
         '-view_name--'         '-PUBLIC-------------'
 
>----+-------------------+-------------------------------------><
     '-WITH GRANT OPTION-'
 

Notes:

  1. ALTER, INDEX, and REFERENCES do not apply to views.

INCLUDE (P)

Inserts declarations or statements into a source program.

>>-INCLUDE----+-SQLCA----------+-------------------------------><
              +-SQLDA----------+
              '-text_file_name-'
 

INSERT (I,P)

Inserts rows into a table or view. Inserting a row in a view inserts the row into the tables on which the view is based.

>>-INSERT INTO----+-table_name-+-------------------------------->
                  '-view_name--'
 
>-----+--------------------------------+------------------------>
      |    .-,------------------.      |
      |    V                    |      |
      '-(-----+-------------+---+---)--'
              '-column_name-'
 
                   .-,-----------------------.
                   V                         |
>-----+-VALUES--(----+-constant-----------+--+---)--+----------><
      |              +-host_variable_list-+         |
      |              +-NULL---------------+         |
      |              '-special_register---'         |
      '-subselect--+---------------+----------------'
                   '-WITH--+-RR-+--'
                           '-CS-'
 

LABEL ON (I,P)

Adds or replaces labels in the catalog descriptions of tables, views, or columns.

>>-LABEL ON----------------------------------------------------->
 
>-----+--| options_a |------------------------IS--str_constant----+>
      |                      .-,--------------------------------.     |
      |                      V                                  |     |
      '--+-table_name-+---(-----column_name--IS--str_constant---+---)-'
         '-view_name--'
 
>--------------------------------------------------------------><
 
options_a
 
|--+-TABLE--+-table_name-+--------------+-----------------------|
   |        '-view_name--'              |
   '-COLUMN--+-table_name.column_name-+-'
             '-view_name.column_name--'
 

LOCK DBSPACE (I,P)

Acquires a shared or exclusive lock on the dbspace-name specified.

>>-LOCK DBSPACE--dbspace_name--IN----+-SHARE-----+--MODE-------><
                                     '-EXCLUSIVE-'
 

LOCK TABLE (I,P)

Acquires a shared or exclusive lock on the named table.

>>-LOCK TABLE--table_name--IN----+-SHARE-----+--MODE-----------><
                                 '-EXCLUSIVE-'
 

OPEN (P)

Opens a cursor.

>>-OPEN--cursor_name----+------------------------------------+-><
                        +-USING--host_variable_list----------+
                        '-USING DESCRIPTOR--descriptor_name--'
 

Extended OPEN CURSOR (P)

Opens a cursor.

>>-OPEN--cursor_variable---------------------------------------->
 
>-----+------------------------------------+-------------------><
      '-USING DESCRIPTOR--descriptor_name--'
 

PREPARE (P)

Prepares an SQL statement for execution from a character string form of the statement.

>>-PREPARE--statement_name--FROM----+-string_constant-+--------><
                                    '-host_variable---'
 

Extended PREPARE (P)

Basic Extended PREPARE

Adds an SQL statement to an existing package.

>>-PREPARE FROM--host_variable---------------------------------><
 
>>-SETTING--section_variable--IN--package_spec------------------>
 
>-----+------------------------------------+-------------------><
      '-USING DESCRIPTOR--descriptor_name--'
 

Single Row Extended PREPARE

Indicates that the SELECT statement in the host-variable is a single row SELECT.

>>-PREPARE SINGLE ROW FROM--host_variable----------------------><
 

>>-SETTING--section_variable--IN--package_spec------------------>
 
>-----+------------------------------------+-------------------><
      '-USING DESCRIPTOR--descriptor_name--'
 

Empty Extended PREPARE

Allows for the creation of an indefinite section in a program.

>>-PREPARE FROM NULL SETTING--section_variable------------------>
 
>----IN--package_spec------------------------------------------><
 

Temporary Extended PREPARE

Prepares the statement in the host-variable and associates the output with a previously created indefinite section.

>>-PREPARE FROM--host_variable--FOR--section_variable----------->
 
>----IN--package_spec------------------------------------------><
 

PUT (P)

Inserts a row into a table.

>>-PUT--cursor-name--------------------------------------------><
 

>>-+------------------------------------+----------------------><
   +-FROM--host-variable-list-----------+
   '-USING DESCRIPTOR--descriptor-name--'
 

Extended PUT (P)

Inserts a row into a table.

>>-PUT--cursor_variable----------------------------------------->
 
>-----+------------------------------------+-------------------><
      +-FROM--host_variable_list-----------+
      '-USING DESCRIPTOR--descriptor_name--'
 

REVOKE Package Privileges (I,P)

Revokes the privilege to execute a package.

                   (1)
>>-REVOKE EXECUTE--------ON--package_name----------------------->
 
           .-,-----------------------.
           V                         |
>----FROM----+-authorization_name-+--+-------------------------><
             |        (2)         |
             '-PUBLIC-------------'
 

Notes:

  1. RUN can be used as a synonym for EXECUTE and is provided for compatibility with previous versions of SQL/DS.

  2. PUBLIC is specified only once.

REVOKE System Authorities (I,P)

Revokes system authorities.

>>-REVOKE------------------------------------------------------->
 
                      .-,-----------------------.
                      V                         |
>-----+-CONNECT FROM----+-authorization_name-+--+-------+------><
      |                 |          (1)       |          |
      |                 '-ALLUSERS-----------'          |
      |                       .-,---------------------. |
      |                       V                       | |
      +--+-DBA------+---FROM-----authorization_name---+-+
      |  '-RESOURCE-'                                   |
      '-SCHEDULE FROM--subsystemid----------------------'
 

Notes:

  1. ALLUSERS can only be specified once.

REVOKE Table Privileges (I,P)

Revokes privileges on a table or view.

                    .-PRIVILEGES-.
>>-REVOKE----+-ALL--+------------+-------+--ON------------------>
             |  .-,--------------------. |
             |  V         (1)          | |
             '----+-ALTER-----------+--+-'
                  +-DELETE----------+
                  |       (1)       |
                  +-INDEX-----------+
                  +-INSERT----------+
                  |            (1)  |
                  +-REFERENCES------+
                  +-SELECT----------+
                  '-UPDATE----------'
 
                            .-,-----------------------.
                            V                         |
>-----+-table_name-+--FROM----+-authorization_name-+--+--------><
      '-view_name--'          |        (2)         |
                              '-PUBLIC-------------'
 

Notes:

  1. The ALTER, INDEX, and REFERENCES options are not applicable to views.

  2. PUBLIC can only be specified once for each statement.

ROLLBACK (I,P)

Ends a logical unit of work without committing any changes.

             .-WORK-.
>>-ROLLBACK--+------+--+---------+-----------------------------><
                       '-RELEASE-'
 

SELECT INTO (P)

Produces a result table consisting of one row, and assigns the values in that row to host variables.

                          .-,---------------------.
                          V                       |
>>-select_clause--INTO-------host_variable_list---+------------->
 
>----from_clause--+--------------+--+-------------+------------><
                  '-where_clause-'  '-with_clause-'
 

UPDATE (I,P)

Updates one or more column values in one or more rows of a table or view. Updating a row of a view updates a row of its base tables.

Searched update (I,P)

>>-UPDATE----+-table_name-+--+------------------+--------------->
             '-view_name--'  '-correlation_name-'
 
          .-,----------------------------------.
          V                                    |
>----SET-----column_name-- = --+-expression-+--+---------------->
                               '-NULL-------'
 
>-----+--------------------------+---+---------------+---------><
      '-WHERE--search_condition--'   '-WITH--+-RR-+--'
                                             '-CS-'
 

Positioned update (P)

>>-UPDATE----+-table_name-+------------------------------------->
             '-view_name--'
 
          .-,-----------------------------.
          V                               |
>----SET-----column_name--+-expression-+--+--------------------->
                          '-NULL-------'
 
>----WHERE CURRENT OF--cursor_name-----------------------------><
 

UPDATE STATISTICS (I,P)

Updates the statistics in the catalog about the tables and indexes.

>>-UPDATE--+-----+--STATISTICS FOR------------------------------>
           '-ALL-'
 
>-----+-TABLE--table_name------+-------------------------------><
      '-DBSPACE--dbspace_name--'
 

WHENEVER (P)

Specifies the action to be taken when a specified exception condition occurs.

>>-WHENEVER----------------------------------------------------->
 
>-----+--+-SQLERROR---+---+-CONTINUE------------------------+-+-><
      |  '-SQLWARNING-'   |      (1)                        | |
      |                   +-STOP----------------------------+ |
      |                   '--+-GOTO--+---+---+--host_label--' |
      |                      '-GO TO-'   '-:-'                |
      '-NOT FOUND--+-CONTINUE------------------------+--------'
                   '--+-GOTO--+---+---+--host_label--'
                      '-GO TO-'   '-:-'
 

Notes:

  1. STOP is not valid for C and FORTRAN.


[ Top of Page | Previous Page | Next Page | Table of Contents ]