Changing the row of a result set with SQL UPDATE

Application

SQL UPDATE changes a row in the result set. The new values of the individual cells are copied by the control from the bound Q parameters. The transaction is defined through the HANDLE to be specified, and the row is defined by the INDEX. The control completely overwrites the already existing rows in the result set.

Requirements

  • Code number 555343
  • Table exists
  • Appropriate table name
  • The names of tables and table columns must start with a letter and must not contain an arithmetic operator (e.g., +). Due to SQL commands, these characters can cause problems when data are input or read.

Description of function

Black arrows and the associated syntax show internal SQL UPDATE processes. Gray arrows and the associated syntax are not directly associated with the SQL UPDATE command.

SQL UPDATE takes all of the columns into consideration that contain the SELECT instruction (SQL command SQL EXECUTE).

The control shows in the defined variable whether the read operation was successful (0) or incorrect (1).

Input

11 SQL UPDATE Q1 HANDLE Q5 index5 RESET UNBOUND

; Complete all rows of transaction Q5 and update table

The NC function includes the following syntax elements:

Syntax element

Meaning

SQL UPDATE

Syntax initiator for the UPDATE SQL command

Q/QL/QR or Q REF

Variable in which the control stores the result

HANDLE

Q parameter with identification of the transaction

INDEX

Row number within the Result set as a number or variable

If not specified, the control accesses line 0.

Optional syntax element

RESET UNBOUND

For the machine manufacturer only

Optional syntax element

Note

When writing to tables, the control checks the lengths of the string parameters. If the entries exceed the length of the columns to be described, then the control outputs an error message.

Example

Transfer line number in the Q parameter

11 SQL BIND Q881 "TAB_EXAMPLE.Position_NR"

12 SQL BIND Q882 "TAB_EXAMPLE.Measure_X"

13 SQL BIND Q883 "TAB_EXAMPLE.Measure_Y"

14 SQL BIND Q884 "TAB_EXAMPLE.Measure_Z"

* - ...

21 SQL Q5 "SELECT Position_NR,Measure_X,Measure_Y,Measure_Z FROM TAB_EXAMPLE"

* - ...

31 SQL FETCH Q1 HANDLE Q5 INDEX+Q2

Program the row number directly

31 SQL UPDATE Q1 HANDLE Q5 INDEX5