7.39.2 ENDSELECT Examples
Example 1: Select and print fields #ORDLIN, #PRODUCT, #QUANTITY and #PRICE from records in an order lines file which have an order number matching what is specified in field #ODRNUM:
SELECT FIELDS(#ORDLIN #PRODUCT #QUANTITY #PRICE) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM)
UPRINT FIELDS(#ORDLIN #PRODUCT #QUANTITY #PRICE)
ENDSELECT
or identically:
GROUP_BY NAME(#ORDERLINE) FIELDS(#ORDLIN #PRODUCT #QUANTITY #PRICE)
SELECT FIELDS(#ORDERLINE) FROM_FILE(ORDLIN) WITH_KEY(#ORDNUM)
UPRINT FIELDS(#ORDERLINE)
ENDSELECT
Example 2: Select and print fields #ORDLIN, #PRODUCT, #QUANTITY and #PRICE from records in an order lines file which have a #QUANTITY value greater than 10 or a #PRICE value less than 49.99
SELECT FIELDS(#ORDLIN #PRODUCT #QUANTITY #PRICE) FROM_FILE(ORDLIN) WHERE('(#QUANTITY *GT 10) *OR (#PRICE *LT 49.99)')
UPRINT FIELDS(#ORDLIN #PRODUCT #QUANTITY #PRICE)
ENDSELECT
or identically:
GROUP_BY NAME(#ORDERLINE) FIELDS(#ORDLIN #PRODUCT #QUANTITY #PRICE)
SELECT FIELDS(#ORDERLINE) FROM_FILE(ORDLIN) WHERE('(#QUANTITY *GT 10) *OR (#PRICE *LT 49.99)')
UPRINT FIELDS(#ORDERLINE)
ENDSELECT
Example 3: Process all "altered" entries from a list named #ORDERLINE. Refer to the DEF_LIST command for more details of lists and list processing.
SELECTLIST NAMED(#ORDERLINE) GET_ENTRYS(*ALTERED)
* << Commands to process the list >>
* << Commands to process the list >>
* << Commands to process the list >>
ENDSELECT