How to Set SQLNAME for Dynamic FRS
When using the SQLVAR with Dynamic FRS statements, a few extra steps are required. These extra steps relate to the differences between Dynamic FRS and Dynamic SQL and are described in the SQL Reference Guide.
When using the SQLDA in a forms input or output using clause, the value of sqlname must be set to a valid field or column name. If the 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 as shown in the following examples.
Windows:
...
01 ROWID PIC X(6).
01 ROWSTATE PIC S9(8) USAGE COMP-5.
...
EXEC FRS DESCRIBE TABLE :FORMNAME :TABLENAME
INTO :SQLDA END-EXEC.
...
ADD 1 TO SQLD.
* Set up to retrieve rowid.
MOVE 20 TO SQLTYPE(SQLD).
MOVE 6 TO SQLLEN(SQLD).
SET SQLIND(SQLD) TO NULL.
MOVE 5 TO SQLNAMEL(SQLD).
MOVE "rowid" TO SQLNAMEC(SQLD)(1:5).
SET SQLDATA(SQLD) TO ADDRESS OF ROWID.
ADD 1 TO SQLD.
* Set up to retrieve _STATE.
MOVE 30 TO SQLTYPE(SQLD).
MOVE 4 TO SQLLEN(SQLD).
SET SQLIND(SQLD) TO NULL.
MOVE 6 TO SQLNAMEL(SQLD).
MOVE "_state" TO SQLNAMEC(SQLD)(1:6).
SET SQLDATA(SQLD) TO ADDRESS OF ROWSTATE.
....
EXEC FRS GETROW :FORMNAME :TABLENAME
USING DESCRIPTOR :SQLDA END_EXEC.
UNIX:
...
01 ROWID PIC X(6).
01 ROWSTATE PIC S9(8) USAGE COMP-5.
...
EXEC FRS DESCRIBE TABLE :FORMNAME :TABLENAME
INTO :SQLDA END-EXEC.
...
ADD 1 TO SQLD.
* Set up to retrieve rowid.
MOVE 20 TO SQLTYPE(SQLD).
MOVE 6 TO SQLLEN(SQLD).
SET SQLIND(SQLD) TO NULL.
MOVE 5 TO SQLNAMEL(SQLD).
MOVE "rowid" TO SQLNAMEC(SQLD)(1:5).
SET SQLDATA(SQLD) TO ADDRESS OF ROWID.
ADD 1 TO SQLD.
* Set up to retrieve _STATE.
MOVE 30 TO SQLTYPE(SQLD).
MOVE 4 TO SQLLEN(SQLD).
SET SQLIND(SQLD) TO NULL.
MOVE 6 TO SQLNAMEL(SQLD).
MOVE "_state" TO SQLNAMEC(SQLD)(1:6).
SET SQLDATA(SQLD) TO ADDRESS OF ROWSTATE.
....
EXEC FRS GETROW :FORMNAME :TABLENAME
USING DESCRIPTOR :SQLDA END_EXEC.
VMS:
...
01 ROWID PIC X(6).
01 ROWSTATE PIC S9(8) USAGE COMP.
...
EXEC FRS DESCRIBE TABLE :FORMNAME :TABLENAME
INTO :SQLDA END-EXEC.
....
ADD 1 TO SQLD.
* Set up to retrieve rowid.
MOVE 20 TO SQLTYPE(SQLD).
MOVE 6 TO SQLLEN(SQLD).
MOVE 0 TO SQLIND(SQLD).
MOVE 5 TO SQLNAMEL(SQLD).
MOVE "rowid" TO SQLNAMEC(SQLD)(1:5).
SET SQLDATA(SQLD) TO REFERENCE OF ROWID.
ADD 1 TO SQLD.
* Set up to retrieve _STATE.
MOVE 30 TO SQLTYPE(SQLD).
MOVE 4 TO SQLLEN(SQLD).
MOVE 0 TO SQLIND(SQLD).
MOVE 6 TO SQLNAMEL(SQLD).
MOVE "_state" TO SQLNAMEC(SQLD)(1:6).
SET SQLDATA(SQLD) TO REFERENCE OF ROWSTATE.
....
EXEC FRS GETROW :FORMNAME :TABLENAME
USING DESCRIPTOR :SQLDA END_EXEC.
You may also set the SQLVAR to point to a datahandler for large object columns. For more information on data handlers, see
Advanced Processing in this chapter.