Define a structure

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
value = %SSC_STRDEF(dbchannel, cursor, element_num, layout_def, rec)


This function returns SSQL_NORMAL (success). (i)


An internal database channel previously initialized using %SSC_INIT and connected by %SSC_CONNECT. (n)


The ID number of an open cursor (opened with %SSC_OPEN). This must be in the range 1 through the number specified by maxcur when the database channel was initialized (with %SSC_INIT). (n)


The number of array elements in each field of rec. (When using element_num, be aware that not all databases support bulk insertions or allow multirow operations. For more information, see %SSC_INIT.) (n)


A record that describes the layout of rec. (a)


The record SQL Connection will use at execution time to bind or define data. The layout_def structure describes the layout for this record. (a)

%SSC_STRDEF provides an alternative way to bind and define data (see Using variables to map data). It’s generally best to use %SSC_OPEN, %SSC_BIND, %SSC_SQLLINK, or %SSC_DEFINE instead. (For the most part, %SSC_STRDEF has been superseded by support for real arrays in these and other SQL Connection functions.) However, use %SSC_STRDEF if

Note that if %SSC_STRDEF follows an %SSC_SQLLINK call, %SSC_STRDEF binds variables only for the original SELECT statement (not the linked statement).

.define ELMNT_NUM 5
.include "ssql.def"
record ar_data                         ;Data record structure
      s_dnum       ,[ELMNT_NUM]i4
      s_dnam       ,[ELMNT_NUM]a6
      s_dman       ,[ELMNT_NUM]d4
      s_ddiv       ,[ELMNT_NUM]a10
static record layout_def
      snm_vars       ,d3               ;Number of variables
      group ssql_vars ,[4]a            ;Array of field
                                       ; definitions
        sfld_typ     ,a1               ;Field type (A/D/I)
        sfld_siz     ,d5               ;Field length
        sfld_dec     ,d2               ;Field decimal point length
record row_count, i4
;Build the structure definition
if.NOT. snm_vars
    snm_vars = 4
    ssql_vars[1].sfld_typ = 'I'
    ssql_vars[1].sfld_siz = 4
    ssql_vars[1].sfld_dec = 0
    ssql_vars[2].sfld_typ = 'A'
    ssql_vars[2].sfld_siz = 6
    ssql_vars[2].sfld_dec = 0
    ssql_vars[3].sfld_typ = 'D'
    ssql_vars[3].sfld_siz = 4
    ssql_vars[3].sfld_dec = 0
    ssql_vars[4].sfld_typ = 'A'
    ssql_vars[4].sfld_siz = 10
    ssql_vars[4].sfld_dec = 0
;Set the SQL statement
sqlp = "SELECT deptnum, deptname, manager, division FROM org"
if (%ssc_open(dbchannel, cur3, sqlp, SSQL_SELECT))
  goto err_exit
;Define the structure for ELMNT_NUM elements in each array
if (%ssc_strdef(dbchannel, cur3, ELMNT_NUM, layout_def, ar_data))
  goto err_exit
;Fetch the five rows at once
sts = %ssc_move(dbchannel, cur3, ELMNT_NUM, row_count)
for ix from 1 thru row_count
    anum = s_dnum[ix]
    writes(1, anum + s_dnam[ix] + %a(s_dman[ix]) + s_ddiv[ix])
if (%ssc_close(dbchannel, cur3))
  goto err_exit.