tableBASE tables can be populated using sequential files extracted from DB2, Oracle, etc. by using a batch import utility such as DK1TEXEC. For more information see the tableBASE Batch Utilities Guide.
A table can also be populated from within an application. Figure 95 is an example of opening a table for write and Figure 96 is an example of inserting rows into the table.
MOVE 'OW' TO NEW-TABLE-COMMAND.
MOVE WRITE-PWD TO PASSWORD.
CALL 'DK1TCALL' USING TB-PARM
NEW-TABLE-COMMAND-AREA
PASSWORD.
The parameter PASSWORD is needed in this example as the existing table has a write password.
Assume there is a table with ten rows, each of which is defined in an array in memory called INPUT-DATA, and that the table is open for write. Figure 96 is an example using the Insert by Key (IK) command to load these ten rows into the table. Note that for brevity the error code and found code checking which should follow each tableBASE command have been omitted from this example.
MOVE 1 TO SUBSCRIPT.
MOVE 'IK' TO NEW-TABLE-COMMAND.
PERFORM UNTIL SUBSCRIPT > 10
MOVE INPUT-DATA (SUBSCRIPT) TO NEW-TABLE-ROW-AREA
CALL 'DK1TCALL' USING TB-PARM
NEW-TABLE-COMMAND-AREA
NEW-TABLE-ROW-AREA
ADD 1 TO SUBSCRIPT
END-PERFORM.
* STORE THE TABLE
MOVE 'ST' TO NEW-TABLE-COMMAND.
CALL 'DK1TCALL' USING TB-PARM
NEW-TABLE-COMMAND-AREA.
* NOW CLOSE THE TABLE
MOVE 'CL' TO NEW-TABLE-COMMAND.
CALL 'DK1TCALL' USING TB-PARM