Creating a new row in the result set with SQL INSERT

Application

SQL INSERT creates a new row in the result set. The values of the individual cells are copied by the control from the bound Q parameters. The transaction is defined via the HANDLE to be specified.

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 associated syntax indicate internal processes of SQL INSERT. The gray arrows and associated syntax do not directly belong to the SQL INSERT command.

SQL INSERT takes all of the columns into consideration that contain the SELECT instruction (SQL command SQL EXECUTE). Table columns without a corresponding SELECT instruction (not contained in the query result) are described by the control with default values.

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

Input

11 SQL INSERT Q1 HANDLE Q5

; Create a new row in transaction Q5

The NC function includes the following syntax elements:

Syntax element

Meaning

SQL INSERT

Syntax initiator for the INSERT SQL command

Q/QL/QR or Q REF

Variable in which the control stores the result

HANDLE

Q parameter with identification of the transaction

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

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"

* - ...

31SQL INSERT Q1 HANDLE Q5