A transaction, 8 a c cessing t a bles with sql commands – HEIDENHAIN TNC 620 (340 56x-03) ISO programming User Manual
Page 231

HEIDENHAIN TNC 620
231
8.8 A
c
cessing T
a
bles with SQL Commands
A Transaction
In principle, a transaction consists of the following actions:
Address the table (file), select rows and transfer them to the result 
set.
Read rows from the result set, change rows or insert new rows.
Conclude transaction: If changes/insertions were made, the rows 
from the result set are placed in the table (file).
Other actions are also necessary so that table entries can be edited in 
an NC program and to ensure that other changes are not made to 
copies of the same table rows at the same time. This results in the 
following transaction sequence:
1
A Q parameter is specified for each column to be edited. The Q 
parameter is assigned to a column—it is "bound" (SQL BIND...).
2
Address the table (file), select rows and transfer them to the result 
set. In addition, you define which columns are transferred to the 
result set (SQL SELECT...).
You can "lock" the selected rows. Other processes can then read 
these rows, but cannot change the table entries. You should 
always lock the selected rows when you are going to make 
changes (SQL SELECT ... FOR UPDATE).
3
Read rows from the result set, change rows or insert new rows:
– Transfer one row of the result set into the Q parameters of your 
NC program (SQL FETCH...).
– Prepare changes in the Q parameters and transfer one row from 
the result set (SQL UPDATE...).
– Prepare new table row in the Q parameters and transfer into the 
result set as a new row (SQL INSERT...).
4
Conclude transaction:
– If changes/insertions were made, the data from the result set is 
placed in the table (file). The data is now saved in the file. Any locks 
are canceled, and the result set is released (SQL COMMIT...).
– If table entries were not changed or inserted (only read access), 
any locks are canceled and the result set is released (SQL 
ROLLBACK... WITHOUT INDEX
).
Multiple transactions can be edited at the same time.
You must conclude a transaction, even if it consists solely 
of read accesses. Only this guarantees that 
changes/insertions are not lost, that locks are canceled, 
and that result sets are released.
