beautypg.com

Sql select, 10 .9 a ccessing t a bles with sql commands – HEIDENHAIN TNC 320 (340 551-01) User Manual

Page 350

background image

350

10 Programming: Q Parameters

1

0

.9 A

ccessing T

a

bles with SQL Commands

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... option. 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... option.
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

option. 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.

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"