6. Embedded SQL for BASIC : BASIC Variables and Data Types : Variable Declarations : Embedded SQL/BASIC Declarations Example
 
Share this page                  
Embedded SQL/BASIC Declarations Example
The following example demonstrates some simple Embedded SQL/BASIC declarations:
exec sql include sqlca
exec sql begin declare section
    declare byte           d_byte ! variables of each data type
    declare word           d_integer2
    declare long           d_integer4
    declare integer        d_integer_def
    declare single         d_real4
    declare double         d_real8
    declare real           d_real_def
    declare decimal(6,2)   d_decimal
    declare string         d_string
    declare integer constant num_depts = 10 ! constant
    common(globs) real e_raise ! static storage variables
    map (ebuf) string ename = 20
    dim string             emp_names(100,30) ! array declarations
    declare integer     dept_id(10)
    common(globs) string e_address(40) = 30
    record person ! Variant record
        byte age
        long flags
        variant
            case
                group emp_list
                    string full_name = 30
                end group
            case
                group emp_directory
                    string firstname = 12
                    string lastname = 8
                end group
        end variant
    end record

declare person p_table(100)           ! Array of records

exec sql include 'employee.dcl'       ! From DCLGEN

external integer empform, deptform    ! Compiled forms
dim word indicators(10)               ! Array of null indicators

exec sql end declare section