ADELIA |
|
|
|
|
(I) |
|
|
|
|
Section for use
INITIALIZATION
Syntax
SQL_SFL_D Query n SeriesVarId WITH SeriesSubstitutionVarId
SeriesVarId |
→ |
SeriesVarId VarId | VarId |
|
|
|
SeriesSubstitutionVarId |
→ |
SeriesSubstitutionVarId SubstitutionVarId |
|
|
| SubstitutionVarId |
Description
This instruction prepares the dynamic SQL query block which will be used to load the subfile, indicated by its number n. It precedes the loading of a subfile.
It is not followed by an "end" instruction, since it controls both the beginning and end of SQL instructions.
It marks the beginning of the dynamic data extraction process from the database (SQL cursor).
Query is the name of a variable which contains the SQL query.
n is the subfile number defined in the layout. Example: 1 for the subfile *1.
SeriesVarId are variables which will receive the values obtained in the query; they often belong to the subfile.
They must be in the exact sequence as those variables obtained in the SQL query.
Variables SubstitutionVarId are represented by a question mark "?" in the query and are replaced at execution time with those variables which are found after the WITH keyword. You can enter multiple "?" in the query. These "?" are replaced with the substitute variables according to the sequence in which they appear after the WITH keyword.
Restrictions
Only one SQL_SFL_D (or SQL_SFL) instruction can be used per subfile.
See also the topic Integrating SQL into ADELIA Programs.
Example
QUERY = *BLANK
QUERY = 'SELECT CUSCOD, CUSNAM FROM CUSTOMER WHERE PAYCOD = ? ORDER BY'
IF SEQUENCE_CODE = '1'
* ordered by customer name
QUERY = QUERY /// ' CUSNAM'
ELSE
* ordered by customer code
QUERY = QUERY /// ' CUSCOD'
END
SQL_SFL_D QUERY 1 ZZ_CUST_CODE ZZ_CUST_NAME WITH ZZ_PAYM_CODE
* ZZ_PAYM_CODE is replacing the question mark in the QUERY variable
* Note that ZZ_CUST_CODE / ZZ_CUST_NAME is the same sequence as
* CUSCOD / CUSNAM
*
CLEAR 1
MANAGE_SFL 1
UPD_SFL
END_MANAGE_SFL
See also the list of 4GL instructions by topic