Description: | Selects the records to be processed in subsequent reads, based on the condition set in the Condition property. |
Used in controls: | DB Access |
Used in objects: | None. |
Parameters: | None. |
Return value: | VT_I4 - ReturnValueS9(9) COMP-5 Zero or greater indicates normal completion. |
Example: | See the SelectRecords Example |
Backward compatibility | SELECTRECORDS |
Backward compatibility | None. |
Example of the SelectRecords Method
The code below shows how to access a table whose structure is:
"JOB_ID" S9(3) <= Specified as the key field
"FUNCTION" X(30)
DATA DIVISION. WORKING-STORAGE SECTION. 01 ReturnValue PIC S9(9) COMP-5. 01 WorkJOBID PIC S9(3). 01 WorkFUNCTION PIC X(30). PROCEDURE DIVISION. *> Connect with the database. *> The return value of the method is stored in ReturnValue. INVOKE CmDb1 "OpenDB" RETURNING ReturnValue. *> Process the return value. : *> Set "JOB_ID" to 500. (key field); Set "FUNCTION" to "DRIVER". MOVE 500 TO "JOB_ID" OF CmDb1. MOVE "TAXI DRIVER" TO "FUNCTION" OF CmDb1. *> Adds a record to the table. *> The return value of the method is stored in ReturnValue. INVOKE CmDb1 "WriteRecord" RETURNING ReturnValue. *> Process the return value. : *> Sets the condition of the database. MOVE "JOB_ID = 500" TO "Condition" OF CmDb1. *> Selects records whose "JOB_ID" field is 500. INVOKE CmDb1 "SelectRecords" RETURNING ReturnValue. *> Process the return value. : *> Reads next record. INVOKE CmDb1 "ReadNextRecord" RETURNING ReturnValue. *> Process the return value. : *> Refers to the value of field. *> WorkJOBID is set to 500 and WorkFUNCTION is set to "TAXI DRIVER". MOVE "JOB_ID" OF CmDb1 TO WorkJOBID. MOVE "FUNCTION" OF CmDb1 TO WorkFUNCTION. : *> Release the database connection. INVOKE CmDb1 "CloseDB".