7.60.3 INSERT Examples
Example 1: Insert fields #CUSTNO, #NAME, #ADDL1 and #POSTCD into a file named CUSTMST that has key:
INSERT FIELDS(#CUSTNO #NAME #ADDL1 #POSTCD) TO_FILE(CUSMST)
or identically:
GROUP_BY NAME(#CUSTOMER) FIELDS(#CUSTNO #NAME #ADDL1 #POSTCD)
INSERT FIELDS(#CUSTOMER) TO_FILE(CUSMST)
Example 2: Request that the user input some customer details. If the customer already exists update the fields, else create a new customer record:
GROUP_BY NAME(#CUSTOMER) FIELDS(#CUSTNO #NAME #ADDL1 #POSTCD)
REQUEST FIELDS(#CUSTOMER)
CHECK_FOR IN_FILE(CUSMST) WITH_KEY(#CUSTNO)
IF_STATUS IS(*EQUALKEY)
UPDATE FIELDS(#CUSTOMER) IN_FILE(CUSMST) WITH_KEY(#CUSTNO)
ELSE
INSERT FIELDS(#CUSTOMER) TO_FILE(CUSMST)
ENDIF
Example 3: Insert all real fields from the currently active version into file CUSMST:
INSERT FIELDS(*ALL_REAL) TO_FILE(CUSMST)
Example 4: Exclude address fields during insertion of a new record into file CUSMST:
GROUP_BY NAME(#XG_ADDR) FIELDS(#ADDL1 #POSTCD)
INSERT FIELDS(*ALL *EXCLUDING #XG_ADDR) TO_FILE(CUSMST)