8 a c cessing t a bles with sql commands – HEIDENHAIN TNC 620 (340 56x-02) ISO programming User Manual
Page 228

228
Programming: Q Parameters
8.8 A
c
cessing T
a
bles with SQL Commands
U
Parameter no. for result:
Q parameter for the
handle. The SQL server returns the handle for the
group of columns and rows selected with the current
select command.
In case of an error (selection could not be carried out),
the SQL server returns the code 1.
Code 0 identifies an invalid handle.
U
Data bank: SQL command text:
with the following
elements:
SELECT
(keyword):
Name of the SQL command. Names of the table
columns to be transferred. Separate column names
with a , (comma) (see examples). Q parameters
must be bound to all columns entered here.
FROM
table name:
Synonym or path and file names of this table. The
synonym is entered directly, whereas the path and
table names are entered in single quotation marks
(see examples of the SQL command, names of the
table columns to be transferred - separate several
columns by a comma). Q parameters must be
bound to all columns entered here.
Optional:
WHERE
selection criteria:
A selection criterion consists of a column name,
condition (see table) and comparator. Link selection
criteria with logical AND or OR. Program the
comparator directly or with a Q parameter. A Q
parameter is introduced with a colon and placed in
single quotation marks (see example).
Optional:
ORDER BY
column name ASC to sort in ascending
order—or
ORDER BY
column name DESC to sort in descending
order.
If neither ASC nor DESC are programmed, then
ascending order is used as the default setting. The
TNC places the selected rows in the indicated
column.
Optional:
FOR UPDATE
(keyword):
The selected rows are locked against write-
accesses from other processes.
Example: Select all table rows
11 SQL BIND Q881 "TAB_EXAMPLE.MEAS_NO"
12 SQL BIND Q882 "TAB_EXAMPLE.MEAS_X"
13 SQL BIND Q883 "TAB_EXAMPLE.MEAS_Y"
14 SQL BIND Q884 "TAB_EXAMPLE.MEAS_Z"
. . .
20 SQL Q5 "SELECT MEAS_NO,MEAS_X,MEAS_Y,
MEAS_Z FROM TAB_EXAMPLE"
Example: Selection of table rows with the WHERE
option
. . .
20 SQL Q5 "SELECT MEAS_NO,MEAS_X,MEAS_Y,
MEAS_Z FROM TAB_EXAMPLE WHERE MEAS_NO<20"
Example: Selection of table rows with the WHERE
option and Q parameters
. . .
20 SQL Q5 "SELECT MEAS_NO,MEAS_X,MEAS_Y,
MEAS_Z FROM TAB_EXAMPLE WHERE
MEAS_NO==:’Q11’"
Example: Table name defined with path and file
name
. . .
20 SQL Q5 "SELECT MEAS_NO,MEAS_X,MEAS_Y,
MEAS_Z FROM ’V:\TABLE\TAB_EXAMPLE’ WHERE
MEAS_NO<20"