Example
In the following example, the defined material is read from the table (WMAT.TAB) and is stored as a text in a QS parameter. The following example shows a possible application and the necessary program steps.
You can use the FN 16 function, for example, in order to reuse QS parameters in your own log files.
0 BEGIN PGM SQL_READ_WMAT MM | |
1 SQL Q1800 "CREATE SYNONYM my_table FOR 'TNC:\table\WMAT.TAB'" | ; Create synonym |
2 SQL BIND QS1800 "my_table.WMAT" | ; Bind QS parameters |
3 SQL QL1 "SELECT WMAT FROM my_table WHERE NR==3" | ; Define search |
4 SQL FETCH Q1900 HANDLE QL1 | ; Execute search |
5 SQL ROLLBACK Q1900 HANDLE QL1 | ; Complete transaction |
6 SQL BIND QS1800 | ; Remove parameter binding |
7 SQL Q1 "DROP SYNONYM my_table" | ; Delete synonym |
8 END PGM SQL_READ_WMAT MM |
Step | Explanation | |
---|---|---|
1 | Create synonym | Assign a synonym to a path (replace long paths with short names)
|
2 | Bind QS parameters | Bind a QS parameter to a table column
|
3 | Define search | A search definition contains the entry of the transfer value
|
4 | Execute search | The control performs the read operation
|
5 | Complete transaction | The transaction is concluded and the used resources are released |
6 | Remove binding | The binding between table columns and QS parameters is removed (release of necessary resources) |
7 | Delete synonym | The synonym is deleted (release of necessary resources) |
Synonyms are an alternative only to the required absolute paths. Relative path entries are not possible.
The following NC program shows the entry of an absolute path.
0 BEGIN PGM SQL_READ_WMAT_2 MM | |
1 SQL BIND QS 1800 "'TNC:\table\WMAT.TAB'.WMAT" | ; Bind QS parameters |
2 SQL QL1 "SELECT WMAT FROM 'TNC:\table\WMAT.TAB' WHERE NR ==3" | ; Define search |
3 SQL FETCH Q1900 HANDLE QL1 | ; Execute search |
4 SQL ROLLBACK Q1900 HANDLE QL1 | ; Complete transaction |
5 SQL BIND QS 1800 | ; Remove parameter binding |
6 END PGM SQL_READ_WMAT_2 MM |