SQL$HELP_OLD72.HLB  —  DECLARE  Variable  Example
    Example 1: Declaring variables in interactive SQL

    SQL> DECLARE :X INTEGER;
    SQL> DECLARE :Y CHAR(10);
    SQL>
    SQL>  BEGIN
    cont>    SET :X = 100;
    cont>    SET :Y = 'Active';
    cont> END;
    SQL> PRINT :X, :Y ;
               X   Y
             100   Active
    SQL> SHOW VARIABLES;
    X                               INTEGER
    Y                               CHAR(10)

    Example 2: Using the values of SQLSTATE in an interactive SQL
    script

    The following simple script uses the named SQLSTATE variable with
    the SIGNAL statement to make the script easier to read.

    @SYS$LIBRARY:SQLSTATE
    set verify;
    begin
    signal :SQLSTATE_DATA_ASSIGN ('Error in assignment');
    end;

    When executed the output appears as shown below.

    SQL> begin
    cont> signal :SQLSTATE_DATA_ASSIGN ('Error in assignment');
    cont> end;
    %RDB-E-SIGNAL_SQLSTATE, routine "(unnamed)" signaled SQLSTATE "22005"
    -RDB-I-TEXT, Error in assignment
    SQL>
Close Help