How to Set SQLNAME for Dynamic FRS
Using the sqlvar with Dynamic FRS statements requires a few extra steps. These extra steps relate to the differences between Dynamic FRS and Dynamic SQL and are described in the Forms-based Application Development Tools User Guide and SQL Reference Guide respectively.
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 a previous describe statement set the name, the program must retain or reset it. If the name refers to a hidden column in a table field, the program must set it directly. If your program sets sqlname directly, it must also set sqlnamel and sqlnamec. You do not need to pad the name portion with blanks or null-terminate it.
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 has to construct the two named columns:
...
char rowid[6+1];
int rowstate;
...
exec frs describe table :formname :tablename
into :sqlda;
...
/* C is zero-based so save before incrementing */
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 = rowid;
sqlda->sqlvar[col_num].sqlind = (short *)0;
sqlda->sqlvar[col_num].sqlname.sqlnamel = 5;
strcpy(sqlda->sqlvar[col_num].sqlname.sqlnamec,
"rowid");
col_num = sqlda-sqld++;
/* Set up to retrieve _STATE */
sqlda->sqlvar[col_num].sqltype = IISQ_INT_TYPE;
sqlda->sqlvar[col_num].sqllen = sizeof(int);
sqlda->sqlvar[col_num].sqldata = &rowstate;
sqlda->sqlvar[col_num].sqlind = (short *)0;
sqlda->sqlvar[col_num].sqlname.sqlnamel = 6;
strcpy(sqlda-sqlvar[col_num].sqlname.sqlnamec,
"_state");
...
exec frs getrow :formname :tablename using descriptor :sqlda;
Last modified date: 04/03/2024