AMB generates the following fields, enabling you to logically terminate the loop structure.
The specific purposes of this call vary depending on the target.
DB-PROCESS REC recordname ... [WHERE keyname operator value [SUB[SCRIPT] value] ... [OF|IN dataarea]] ... [DB-PROCESS-ID name] [INTO dataarea] [HOLD] [RESET] ... [VIEW|PCB pcbname] Controlled logic block
DB-PROCESS REC recordname ... [DB-PROCESS-ID name] [INTO dataarea] ... [HOLD] [RESET] ... [VIEW|PCB pcbname] Controlled logic block
Process CUST-RECORD; execute logic upon each successful read. Note that CUST-PROCESS-CTR serves as a subscript for the screen fields.
DB-PROCESS REC CUST-RECORD ... WHERE CUST-KEY >= SCREEN-KEY ... DB-PROCESS-ID CUST IF CUST-PROCESS-CTR > SCREEN-MAX TRUE CUST-END-PROCESS ELSE SCREEN-CUST (CUST-PROCESS-CTR) = CUST-NAME SCREEN-PHONE (CUST-PROCESS-CTR) = CUST-PHONE SCREEN-ADDRESS (CUST-PROCESS-CTR) = CUST-ADDRESS IF NTF-ON-REC SCREEN-MSG = 'CUSTOMER NOT FOUND' ELSE-IF END-ON-REC SCREEN-MSG = 'END OF CUSTOMER RECORDS'
/* Begin process loop DB-PROCESS REC recordname ... WHERE keyname operator value keywords ... [DB-PROCESS-ID name] IF APS-PROCESS-CTR|name-PROCESS-CTR > value /* End process loop TRUE APS-END-PROCESS|name-END-PROCESS ELSE /* User-written record processing logic IF ... /*Logic executed after process loop termination /* Includes file status checking
Unqualified - select all columns.
DB-PROCESS REC copylibname-REC ... [DB-PROCESS-ID name] ... [DB-LOOP-MAX=number] ... [FETCH ONLY|READ ONLY] ... [FETCH FIRST numberofrows] ... [WITH [CS|RS|RR|UR]] ... [SENSITIVE [DYNAMIC | STATIC] SCROLL CURSOR|INSENSITIVE SCROLL CURSOR] ... [WITH ROWSET POSITIONING FOR number ROWS] ... [QUERYNO number] ... [WITH HOLD] ... [OPTIMIZE number] ... [UPDATE|ORDER ... column1 [ASC|DESC] [...columnN [ASC|DESC]]] ... [INTO dataname] Controlled logic block
Qualified - select all columns.
DB-PROCESS REC copylibname-REC ... [DB-PROCESS-ID name] ... [FETCH ONLY|READ ONLY] ... [FETCH FIRST numberofrows] ... [WITH [CS|RS|RR|UR]] ... [SENSITIVE [DYNAMIC | STATIC] SCROLL CURSOR|INSENSITIVE SCROLL CURSOR] ... [WITH ROWSET POSITIONING FOR number ROWS] ... [QUERYNO number] ... [WITH HOLD] ... [OPTIMIZE number] ... WHERE column operator [[:]]altvalue]|column ... [AND|OR column operator [[:]altvalue]|column] . . . ... [AND|OR column operator [[:]altvalue]|column] ... [DB-LOOP-MAX=number] ... [UPDATE|ORDER ... column1 [ASC|DESC] [...columnN [ASC|DESC]]] ... [INTO dataname] Controlled logic block
DB-PROCESS REC copylibname-REC ... [DB-PROCESS-ID name] ... [DISTINCT] ... [FETCH ONLY|READ ONLY] ... [FETCH FIRST numberofrows] ... [WITH [CS|RS|RR|UR]] ... [SENSITIVE [DYNAMIC | STATIC] SCROLL CURSOR|INSENSITIVE SCROLL CURSOR] ... [WITH ROWSET POSITIONING FOR number ROWS] ... [QUERYNO number] ... [WITH HOLD] ... [OPTIMIZE number] ... column1 [(altvalue)] [AS name] [... columnN [(altvalue)]] ... WHERE column operator [[:]altvalue]|column ... [AND|OR column operator [[:]altvalue]|column] . . . ... [AND|OR column operator [[:]altvalue]|column] ... [DB-LOOP-MAX=number] ... [UPDATE|ORDER ... column1 [ASC|DESC] [...columnN [ASC|DESC]]] Controlled logic block
Join columns from two or more tables:
DB-PROCESS REC correlname.copylibname-REC ... [DB-PROCESS-ID name] ... [DISTINCT] ... [FETCH ONLY|READ ONLY] ... [FETCH FIRST numberofrows] ... [WITH [CS|RS|RR|UR]] ... [SENSITIVE [DYNAMIC | STATIC] SCROLL CURSOR|INSENSITIVE SCROLL CURSOR] ... [WITH ROWSET POSITIONING FOR number ROWS] ... [QUERYNO number] ... [WITH HOLD] ... [OPTIMIZE number] ... [column1 [(altvalue)][AS name][... columnN [(altvalue)]]] ... REC correlname.copylibname-REC ... [column1 [(altvalue)] [... columnN [(altvalue)]]] . . . ... [WHERE correlname.column oper ... [[:]altval]|correlname.column ... [AND|OR correlname.column oper ... [[:]altval]|correlname.col] . . . ... [AND|OR correlname.column oper ... [[:]altval]|correlname.col] ... [DB-LOOP-MAX=number] ... [ORDER ... column1 [ASC|DESC] [...columnN [ASC|DESC]]] Controlled logic block
DB-PROCESS REC copylibname-REC ... [DB-PROCESS-ID name] ... [DISTINCT] ... [FETCH ONLY|READ ONLY] ... [FETCH FIRST numberofrows] ... [SENSITIVE [DYNAMIC | STATIC] SCROLL CURSOR|INSENSITIVE SCROLL CURSOR] ... [WITH ROWSET POSITIONING FOR number ROWS] ... [WITH [CS|RS|RR|UR]] ... [QUERYNO number] ... [WITH HOLD] ... [OPTIMIZE number] ... [column1 [(altvalue)] [AS name] [... columnN [(altvalue)]]] ... [WHERE column operator [[:]altvalue]|column ... [AND|OR column operator [[:]altvalue]|column] . . . ... [AND|OR column operator [[:]altvalue]|column]] ... [DB-LOOP-MAX=number] ... UNION [ALL] DB-OBTAIN REC copylibname-REC . . . ... [ORDER ... column1 [ASC|DESC] [...columnN [ASC|DESC]]] Controlled logic block
Specify a Join using a join operator.
DB-PROCESS REC correlname1.copylibname-REC ... [DB-PROCESS-ID name] ... [DISTINCT] ... [FETCH ONLY|READ ONLY] ... [FETCH FIRST numberofrows] ... [SENSITIVE [DYNAMIC | STATIC] SCROLL CURSOR|INSENSITIVE SCROLL CURSOR] ... [WITH ROWSET POSITIONING FOR number ROWS] ... [WITH [CS|RS|RR|UR]] ... [QUERYNO number] ... [WITH HOLD] ... [OPTIMIZE number] ... [column1 [AS name] [... columnN]]|[NONE] . . . ... [[INNER JOIN|RIGHT OUTER JOIN|LEFT OUTER JOIN|FULL OUTER JOIN] ... ON joincondition] ... REC correlnameN.copylibname-REC ... [column1 [AS name] [... columnN]]|[NONE] ... [WHERE correlname.column1 oper ... [:]value|correlname.column2 ... [AND|OR correlname.column3 oper ... [:]value|correlname.column4 . . . ... AND|OR correlname.columnN op ... [:]value|correlname.columnN]] ... [DB-LOOP-MAX=number] ... [ORDER ... column1 [ASC|DESC] [...columnN [ASC|DESC]]] Controlled logic block
01 recordname-ARR. 05 CobolHostVar1-ARR picture occurs row-number times. 05 IND-CobolHostVar1-ARR picture occurs row-number times. 05 CobolHostVar2-ARR picture occurs row-number times. 05 IND-CobolHostVar2-ARR picture occurs row-number times. ….. 05 CobolHostVarn-ARR picture occurs row-number times. 05 IND-CobolHostVarn-ARR picture occurs row-number times.
Declare, name, and open a cursor; retrieve all rows and columns; process only one row from duplicate rows; close the cursor; move data into an alternate area.
DB-PROCESS REC D2TAB-REC ... DB-PROCESS-ID D2MAST-ID ... DISTINCT ... INTO WS-D2MAST-RECORD
Eliminate duplicate rows from the cursor set (rows with matching data in columns PM_PART_NO, PM_COLOR, IN_PART_NO, and IN_COLOR are considered duplicates). Sort cursor set in ascending order by D2MASTER columns PM_PART_NO and PM_COLOR.
DB-PROCESS REC A.D2TAB-REC ... DB-PROCESS-ID D2MAST-ID ... DISTINCT ... PM_PART_NO PM_COLOR ... REC B.D2INVEN-REC ... IN_PART_NO IN_COLOR ... WHERE A.PM_PART_NO = B.IN_PART_NO ... AND A.PM_PART_SHORT_DESC = ... :WS-PART-SHORT-DESC ... AND B.IN_QTY_ONHAND > 100 ... DB-LOOP-MAX=999 ... ORDER A.PM_PART_NO ASC ... A.PM_COLOR ASC
Join a table to itself. Retrieve records where the IN_QTY_ONHAND column is greater than 100 and retrieve records whose IN_DATA_LAST_ORDER column matches these records.
DB-PROCESS REC A.D2INVEN-REC ... DB-PROCESS-ID D2MAST-ID ... IN_PART_NO ....IN_QTY_ONHAND ... IN_DATE_LAST_ORDER ... REC B.D2INVEN-REC ... IN_PART_NO (:WS-PART-NO) ... IN_QTY_ONHAND (:WS-QTY-ONHAND) ... WHERE A.IN_DATA_LAST_ORDER = B.IN_DATE_LAST_ORDER ... AND A.IN_QTY_ONHAND > 100
DB-PROCESS ... REC A.ACCTMAST-REC ... LEFT OUTER JOIN ... ON A.ACCOUNT_NUMBER = B.ACCOUNT_NUMBER ... REC B.EMSTOCK-REC ... WHERE DIVIDENDS IS NOT NULL ... DB-PROCESS-ID PX24
DB-PROCESS ... REC A.EMSTOCK-REC ... A.ACCOUNT_NUMBER (WS-ACCOUNT-NUMBER-1) ... A.CUSTOMER_NAME ... INNER JOIN ... ON A.ACCOUNT_NUMBER = C.ACCOUNT_NUMBER ... REC B.EMSAVING-REC ... B.DEPOSITS (WS-DEPOSITS) ... INNER JOIN ... ON C.ACCOUNT_NUMBER = A.ACCOUNT_NUMBER ... REC C.ACCTMAST-REC ... C.ACCOUNT_TYPE (WS-ACCOUNT-TYPE) ... C.CITY ... WHERE C.CITY IS NOT NULL ... DB-PROCESS-ID CSR2
Use both a LEFT OUTER JOIN and a FULL OUTER JOIN.
DB-PROCESS ... REC A.EMSTOCK-REC ... A.ACCOUNT_NUMBER (WS-ACCOUNT-NUMBER-1) ... A.CUSTOMER_NAME ... LEFT OUTER JOIN ... ON A.ACCOUNT_NUMBER = C.ACCOUNT_NUMBER ... REC B.EMSAVING-REC ... B.DEPOSITS (WS-DEPOSITS) ... FULL OUTER JOIN ... ON C.ACCOUNT_NUMBER = A.ACCOUNT_NUMBER ... REC C.ACCTMAST-REC ... C.ACCOUNT_TYPE (WS-ACCOUNT-TYPE) ... C.CITY ... REC A.EMSTOCK-REC ... A.ENDING_BALANCE ... WHERE C.CITY IS NOT NULL ... DB-PROCESS-ID CSR7
This example shows a DB-PROCESS with both a LEFT OUTER join and a RIGHT OUTER join, usage of the AS clause, and usage of SQL Functions ABS, and ROUND:
DB-PROCESS ... REC A.ACCTMAST-REC ... ACCOUNT_NUMBER ... LEFT OUTER JOIN ... ON A.ACCOUNT_NUMBER = B.ACCOUNT_NUMBER ... REC B.EMSTOCK-REC ... DIVIDENDS ... ABS((BEGIN_BALANCE),WS-ABS,'N') AS ABSX ... ROUND((CHANGE, 1),WS-CHANGE-ROUNDED,'N') AS ROUNDX ... RIGHT OUTER JOIN ... ON A.ACCOUNT_NUMBER = C.ACCOUNT_NUMBER ... AND A.ACCOUNT_NUMBER = '11111' ... REC C.EMSAVING-REC ... ABS((DEPOSITS),WS-DEPOSITS,'N') AS DEPOSITX ... WITHDRAWALS ... WHERE DEPOSITS IS NOT NULL ... ORDER BY ABSX, ROUNDX ... DB-PROCESS-ID PX03
This example shows a DB-PROCESS using the FOR READ ONLY, FETCH FIRST, WITH, and QUERYNO clauses, INSENSITIVE SCROLL CURSOR, and SQL functions LOWER and RIGHT:
DB-PROCESS ... REC A.ACCTMAST-REC ... CUSTOMER_NUMBER ... LOWER(CUSTOMER_NAME) ... ACCOUNT_NUMBER ... ACCOUNT_TYPE ... ADDRESS_1 ... ADDRESS_2 ... RIGHT((CITY,5),WS-CITY-SHORT,'Y') ... STATE ... ZIP_CODE ... WHERE ( ... CUSTOMER_NUMBER = #MASTX-CUSTNO ... ) AND ... ((A.CUSTOMER_NUMBER = #PX-FWDX-ACCTMASTER-0001 AND ... A.ACCOUNT_NUMBER > #PX-FWDX-ACCTMASTER-0002 ) ... OR ... (A.CUSTOMER_NUMBER > #PX-FWDX-ACCTMASTER-0001 )) ... ORDER ... 01 ... 03 ... DB-PROCESS-ID PX01 ... READ ONLY ... INSENSITIVE SCROLL CURSOR ... WITH CS ... QUERYNO 2 ... FETCH FIRST 40
/* Begin process loop DB-PROCESS REC recordname /* Custom row processing code IF APS-PROCESS-CTR|name-PROCESS-CTR > value /* End process loop TRUE APS-END-PROCESS|name-END-PROCESS ELSE /* Custom record processing logic /* Can include file status /* Logic executed after process loop termination /* Can include file status checking
This example shows use of a sensitive dynamic scroll cursor:
DB-PROCESS ... REC A.ACCTMAST-REC ... CUSTOMER_NUMBER ... CUSTOMER_NAME ... ACCOUNT_NUMBER ... ACCOUNT_TYPE ... WHERE ... ACCOUNT_NUMBER = '111111' ... DB-PROCESS-ID THS-CSR1 ... SENSITIVE DYNAMIC SCROLL CURSOR
This example shows ROWSET positioning:
DB-PROCESS ... REC A.ACCTMAST-REC ... CUSTOMER_NUMBER ... CUSTOMER_NAME ... ACCOUNT_NUMBER ... ACCOUNT_TYPE ... WHERE ... ACCOUNT_NUMBER = '111111' ... DB-PROCESS-ID THS-CSR3 ... SENSITIVE SCROLL CURSOR WITH ROWSET POSITIONING ... FOR 9 ROWS
This example shows a multiple row insert:
DB-STORE ... REC ACCTMAST-REC ... CUSTOMER_NUMBER (:CUSTOMER-NUMBER-ARR) ... CUSTOMER_NAME (:CUSTOMER-NAME-ARR) ... ACCOUNT_NUMBER (:ACCOUNT-NUMBER-ARR) ... ACCOUNT_TYPE (DEFAULT) ... FOR 5 ROWS ... NOT ATOMIC
This example shows storing multiple rows:
DB-STORE REC D2MASTER-REC FOR 10 ROWS
DB-PROCESS REC recordname WHERE keyname operator value ... [DB-PROCESS-ID name] [SUB value] ... [OF dataarea] [INTO dataarea] Controlled logic block
DB-PROCESS REC recordname [VIEW keyname] ... [DB-PROCESS-ID name] [INTO dataarea] [RESET] Controlled logic block
See also the section All Formats - Stand-alone Applications below.
Process CUST-RECORD; execute logic upon each successful read. Note that CUST-PROCESS-CTR serves as a subscript for the screen fields.
DB-PROCESS REC CUST-RECORD ... WHERE CUST-KEY >= SCREEN-KEY ... DB-PROCESS-ID CUST IF CUST-PROCESS-CTR > SCREEN-MAX TRUE CUST-END-PROCESS ELSE SCREEN-CUST (CUST-PROCESS-CTR) = CUST-NAME SCREEN-PHONE (CUST-PROCESS-CTR) = CUST-PHONE SCREEN-ADDRESS (CUST-PROCESS-CTR) = CUST-ADDRESS IF NTF-ON-REC SCREEN-MSG = 'CUSTOMER NOT FOUND' ELSE-IF END-ON-REC SCREEN-MSG = 'END OF CUSTOMER RECORDS'
/* Begin process loop DB-PROCESS REC recordname ... WHERE keyname operator value keywords ... [DB-PROCESS-ID name] IF APS-PROCESS-CTR|name-PROCESS-CTR > value /* End process loop TRUE APS-END-PROCESS|name-END-PROCESS ELSE /* User-written record processing logic IF ... /*Logic executed after process loop termination /* Includes file status checking
DB-PROCESS REC recordname WHERE keyname operator value ... [DB-PROCESS-ID name] [SUB value] ... [OF dataarea] [INTO dataarea] ... [KLEN value] [HOLD] [PREV] ... [REQID number] [SYSID systemname] ... [DDN ddname] Controlled logic block
DB-PROCESS REC recordname ... [DB-PROCESS-ID name] [INTO dataarea] ... [HOLD] [PREV] [RESET] ... [REQID number] [SYSID systemname] ... [VIEW keyname] [DDN ddname] Controlled logic block
Process CUST-RECORD; execute logic upon each successful read. Note that CUST-PROCESS-CTR serves as a subscript for the screen fields.
DB-PROCESS REC CUST-RECORD ... WHERE CUST-KEY >= SCREEN-KEY ... DB-PROCESS-ID CUST IF CUST-PROCESS-CTR > SCREEN-MAX TRUE CUST-END-PROCESS ELSE SCREEN-CUST (CUST-PROCESS-CTR) = CUST-NAME SCREEN-PHONE (CUST-PROCESS-CTR) = CUST-PHONE SCREEN-ADDRESS (CUST-PROCESS-CTR) = CUST-ADDRESS IF NTF-ON-REC SCREEN-MSG = 'CUSTOMER NOT FOUND' ELSE-IF END-ON-REC SCREEN-MSG = 'END OF CUSTOMER RECORDS'
/* Begin process loop DB-PROCESS REC recordname ... WHERE keyname operator value keywords ... [DB-PROCESS-ID name] IF APS-PROCESS-CTR|name-PROCESS-CTR > value /* End process loop TRUE APS-END-PROCESS|name-END-PROCESS ELSE /* User-written record processing logic IF ... /*Logic executed after process loop termination /* Includes file status checking
/* Begin process loop DB-PROCESS REC recordname /* Custom row processing code IF APS-PROCESS-CTR|name-PROCESS-CTR > value /* End process loop TRUE APS-END-PROCESS|name-END-PROCESS ELSE /* Custom record processing logic /* Can include file status checking /* Logic executed after process loop termination /* Can include file status checking
SYM1 % &prefix-LOOP-MAX = 200