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

DEFINE

Use the DEFINE statement to declare local variables that an SPL routine uses, or to declare global variables that can be shared by several SPL routines.

Syntax

Read syntax diagramSkip visual syntax diagram>>-DEFINE------------------------------------------------------->
 
             .-,-------.
             V         |                                          (1)
>--+-GLOBAL----SPL_var-+--+-data_type--DEFAULT--| Default Value |------+-+-->
   |                      '-REFERENCES--+-BYTE-+--DEFAULT NULL---------' |
   |                                    '-TEXT-'                         |
   | .-,-------.                                                         |
   | V         |                                                         |
   '---SPL_var-+--+-data_type------------------------------------------+-'
                  +-REFERENCES--+-BYTE-+-------------------------------+
                  |             '-TEXT-'                               |
                  +-LIKE--+-view----+--.--column-----------------------+
                  |       +-synonym-+                                  |
                  |       '-table---'                                  |
                  +---PROCEDURE----------------------------------------+
                  |  (2)                                               |
                  '------+-+-BLOB-+----------------------------------+-'
                         | '-CLOB-'                                  |
                         |                                    (3)    |
                         '-+-| Subset of Complex Data Types |------+-'
                           +-distinct_type-------------------------+
                           '-opaque_type---------------------------'
 
>--;-----------------------------------------------------------><
 
Notes:
  1. See ***
  2. Dynamic Server only
  3. See Subset of Complex Data Types (IDS)
Element Description Restrictions Syntax
column Column name Must already exist in the table or view Data Type
data_type Type of SPL_var See Declaring Global Variables. Data Type
distinct_type A distinct type Must already be defined in the database Identifier
opaque_type An opaque type Must already be defined in the database Identifier
SPL_var New SPL variable Must be unique within statement block Identifier
synonym,
table, view
Name of a table,
view, or synonym
Synonym and the table or view to which it points must exist when DEFINE is issued Database Object Name

Usage

The DEFINE statement is not an executable statement. The DEFINE statement must appear after the routine header and before any other statements. If you declare a local variable (by using DEFINE without the GLOBAL keyword), its scope of reference is the statement block in which it is defined. You can use the variable within the statement block. Another variable outside the statement block with a different definition can have the same name.

A variable with the GLOBAL keyword is global in scope and is available outside the statement block and to other SPL routines. Global variables can be any built-in data type except SERIAL, SERIAL8, TEXT, BYTE, CLOB, or BLOB. Local variables can be any built-in data type except SERIAL, SERIAL8, TEXT, or BYTE. If column is of the SERIAL or SERIAL8 data type, declare an INT or INT8 variable (respectively) to store its value.

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