beautypg.com

Sql select – HEIDENHAIN TNC 620 (73498x-02) User Manual

Page 304

background image

Programming: Q Parameters

9.9

Accessing tables with SQL commands

9

304

TNC 620 | User's Manual

HEIDENHAIN Conversational Programming | 5/2013

SQL SELECT

SQL SELECT selects table rows and transfers them to the result set.
The SQL server places the data in the result set row-by-row. The
rows are numbered in ascending order, starting from 0. This row
number, called the

INDEX, is used in the SQL commands "Fetch" and

"Update."

Enter the selection criteria in the

SQL SELECT...WHERE... function.

This lets you restrict the number of rows to be transferred. If you do
not use this option, all rows in the table are loaded.

Enter the sorting criteria in the

SQL SELECT...ORDER BY... function.

Enter the column designation and the keyword for ascending/
descending order. If you do not use this option, the rows are placed
in random order.

Lock out the selected rows for other applications with the

SQL

SELECT...FOR UPDATE function. Other applications can continue to
read these rows, but cannot change them. We strongly recommend
using this option if you are making changes to the table entries.

Empty result set

: If no rows match the selection criteria, the SQL

server returns a valid handle but no table entries.

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.
With an error (selection could not be executed) the
SQL server returns a 1. Code 0 identifies an invalid
handle.

Database: 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 name of this table. The
synonym is entered directly: the path name and
table name 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 (see examples).
Q parameters must be bound to all columns
entered here.

Select all table rows

11SQL BIND Q881

"TAB_EXAMPLE.MEAS_NO"
12SQL BIND Q882

"TAB_EXAMPLE.MEAS_X"
13SQL BIND Q883

"TAB_EXAMPLE.MEAS_Y"
14SQL BIND Q884

"TAB_EXAMPLE.MEAS_Z"
. . .
20SQL Q5 "SELECT

MEAS_NO,MEAS_X,MEAS_Y, MEAS_Z

FROM TAB_EXAMPLE"

Selection of table rows with the
WHERE function

. . .
20SQL Q5 "SELECT

MEAS_NO,MEAS_X,MEAS_Y, MEAS_Z

FROM TAB_EXAMPLE WHERE

MEAS_NO<20"

Selection of table rows with the
WHERE function and Q parameters

. . .
20SQL Q5 "SELECT

MEAS_NO,MEAS_X,MEAS_Y, MEAS_Z

FROM TAB_EXAMPLE WHERE

MEAS_NO==:'Q11'"

Table name defined with path and file
name

. . .
20SQL Q5 "SELECT

MEAS_NO,MEAS_X,MEAS_Y, MEAS_Z

FROM 'V:\TABLE\TAB_EXAMPLE' WHERE

MEAS_NO<20"