Was this helpful?
How to Set SQLNAME for Dynamic FRS
A few extra steps are required when you use the sqlvar with Dynamic FRS statements. These extra steps relate to the differences between Dynamic FRS and Dynamic SQL and are described in the SQL Reference Guide and the Forms-based Application Development Tools User Guide.
When using the SQLDA in a forms input or output using clause, set the sqlname to a valid field or column name. If this name was set by a previous describe statement, it must be retained or reset by the program. If the name refers to a hidden table field column, the program must set sqlname directly. If your program sets sqlname directly, it must also set sqlnamel and sqlnamec. The name portion does not need to be padded with blanks.
For example, a dynamically named table field has been described, and the application always initializes any table field with a hidden 6-byte character column called "rowid." The code used to retrieve a row from the table field including the hidden column and _state variable would have to construct the two named columns.
UNIX:
...
     character*6 rowid
         integer*4 rowstate
...

     exec frs describe table :formname :tablename 
    1     into :sqlda
...

     sqlda.sqld = sqlda.sqld + 1
         col_num = sqlda.sqld
C Set up to retrieve rowid
         sqlda.sqlvar(col_num).sqltype = IISQ_CHA_TYPE
         sqlda.sqlvar(col_num).sqllen = 6
         sqlda.sqlvar(col_num).sqldata = loc(rowid)
         sqlda.sqlvar(col_num).sqlind = 0
         sqlda.sqlvar(col_num).sqlname.sqlnamel = 5
    sqlda.sqlvar(col_num).sqlname.sqlnamec(1:5) = 'rowid'
         sqlda.sqld = sqlda.sqld + 1
         col_num = sqlda.sqld
C Set up to retrieve _STATE
         sqlda.sqlvar(col_num).sqltype = IISQ_INT_TYPE
         sqlda.sqlvar(col_num).sqllen = 4
         sqlda.sqlvar(col_num).sqldata = loc(rowstate)
         sqlda.sqlvar(col_num).sqlind = 0
         sqlda.sqlvar(col_num).sqlname.sqlnamel = 6
         sqlda.sqlvar(col_num).sqlname.sqlnamec(1:6)
    1                                       = '_state'
...

     exec frs getrow :formname :tablename using
    1       descriptor :sqlda  
VMS:
...
     character*6 rowid
     integer*4 rowstate
...

     exec frs describe table :formname :tablename 
    1     into :sqlda
...

     sqlda.sqld = sqlda.sqld + 1
     col_num = sqlda.sqld
! Set up to retrieve rowid
     sqlda.sqlvar(col_num).sqltype = IISQ_CHA_TYPE
     sqlda.sqlvar(col_num).sqllen = 6
     sqlda.sqlvar(col_num).sqldata = %loc(rowid)
     sqlda.sqlvar(col_num).sqlind = 0
     sqlda.sqlvar(col_num).sqlname.sqlnamel = 5
     sqlda.sqlvar(col_num).sqlname.sqlnamec(1:5) = 'rowid'
     sqlda.sqld = sqlda.sqld + 1
     col_num = sqlda.sqld
! Set up to retrieve _STATE
     sqlda.sqlvar(col_num).sqltype = IISQ_INT_TYPE
     sqlda.sqlvar(col_num).sqllen = 4
     sqlda.sqlvar(col_num).sqldata = %loc(rowstate)
     sqlda.sqlvar(col_num).sqlind = 0
     sqlda.sqlvar(col_num).sqlname.sqlnamel = 6
     sqlda.sqlvar(col_num).sqlname.sqlnamec(1:6) 
    1                                       = '_state'
...

     exec frs getrow :formname :tablename using
    1        descriptor:sqlda 
Windows:
...
     character*6 rowid
         integer*4 rowstate
...

     exec frs describe table :formname :tablename 
    1     into :sqlda
...

     sqlda.sqld = sqlda.sqld + 1
         col_num = sqlda.sqld
C Set up to retrieve rowid
         sqlda.sqlvar(col_num).sqltype = IISQ_CHA_TYPE
         sqlda.sqlvar(col_num).sqllen = 6
         sqlda.sqlvar(col_num).sqldata = loc(rowid)
         sqlda.sqlvar(col_num).sqlind = 0
         sqlda.sqlvar(col_num).sqlname.sqlnamel = 5
    sqlda.sqlvar(col_num).sqlname.sqlnamec(1:5) = 'rowid'
         sqlda.sqld = sqlda.sqld + 1
         col_num = sqlda.sqld
C Set up to retrieve _STATE
         sqlda.sqlvar(col_num).sqltype = IISQ_INT_TYPE
         sqlda.sqlvar(col_num).sqllen = 4
         sqlda.sqlvar(col_num).sqldata = loc(rowstate)
         sqlda.sqlvar(col_num).sqlind = 0
         sqlda.sqlvar(col_num).sqlname.sqlnamel = 6
         sqlda.sqlvar(col_num).sqlname.sqlnamec(1:6)
    1                                       = '_state'
...

     exec frs getrow :formname :tablename using
    1       descriptor :sqlda  
Last modified date: 08/28/2024