ADELIA |
VADELIA |
SADELIA |
WADELIA |
EADELIA |
(I/B) |
(I/B) (S) |
(B) (S) |
(I/B) (S) |
(B) (S) |
Warning:
- In the case of ADELIA programs, this instruction is only compatible with the RPG generator.
- This instruction can only be used in server blocks, not in client blocks.
Section for use
All
Syntax
LOAD_SQL_LST ListName SeriesEntities Distinct Condition SortOption
SeriesEntities |
→ |
SeriesEntities, Entity | Entity |
Entity |
→ |
EntityName CorrelationName |
| EntityName |
Distinct |
→ |
*DISTINCT | None |
Condition |
→ |
AdeliaCondition | *COND(:VarId) | *COND(:SQLStatement) |
Description
This instruction reads the entity or entities SeriesEntities, obeying the (optional) condition Condition, and inserts the values of the fields in the entities into the fields in the list ListName. The fields in the list must have the same names as those in the entities.
If *DISTINCT is specified, only the distinct lines will be loaded (in relation to the list columns which have the same name as the entities' fields and any sort fields).
The read operation can follow an order concerning certain fields, the order being defined by the SortOption element.
Click here for the explanation of the SortOption element.
The condition can also be contained in an alphanumeric variable or in a SQL statement previously declared via the SQL_STATEMENT instruction, and must contain the "where" part of an SQL query.
Warning: In these cases, you must specify the real name of the columns, not the Adelia names.
After the instruction has been run, it is possible to test the SQL return code using the reserved word *SQLCODE.
Example
* loads the list of customers in the list CUSTLST
LOAD_SQL_LST CUSTLST CUSTOMERS *COND(CCUST_COUNTRY = :WCOUNTRY) *SORT(CCUST_NAME)
WREQUEST = 'CCUST_COUNTRY = ' 'France' ' OR CCUST_COUNTRY = ' 'USA' ' '
LOAD_SQL_LST CUSTLST2 CUSTOMERS *COND(:WREQUEST) *SORT(CCUST_NAME)
* In the DECL PGM section, declaration of a list (Visual Adelia syntax) with the names of its file fields:
LIST LST1_PCODE PDESCRIP PPRICE
...
LOAD_SQL_LST LST1_PROD PRODUCT *COND(PPRO_COD START_WITH :ZPRO_COD)
* In the DECL PGM section, declaration of a list (Adelia syntax) with the names of its file fields:
DECL LIST LST1_PCODE PDESCRIP PPRICE
...
LOAD_SQL_LST LST1_PROD PRODUCT *COND(PPRO_COD START_WITH :ZPRO_COD)