Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | table |
The grammar for the command string is SQL-like and is described in Note 199.
Between SELECT and FROM, you can give some column names (separated by
commas). Then the output table will contain those columns only. If no
column names are given, all columns will be selected. E.g.:
SELECT column1, column2,column3 FROM table.in GIVING table.out
The WHERE part (like column1*column2>10) contains an arbitrary expression. Functions (like sin, max, ceil) are supported. Only scalar columns (or keywords) can be used in the expression. Complex numbers must be given as, for example, 3.4+4i (similar to Glish). With some extra syntax (not explained here) it is even possible to use keywords from other tables in the expression. Rows obeying the WHERE expression will be selected.
Sorting can be done with the ORDERBY clause. You can give there any
number of (scalar) columns separated by commas. You can use a mix of
ascending (is default) and descending. E.g.:
ORDERBY column1 DESC, column2, column3 ASC, column4 DESC
The GIVING clause defines the output table containing the requested rows and columns. It can be used as any other table.
Each part (column list, WHERE, ORDERBY) is optional, but at least one of them should be given. Otherwise no operation would be done on the input table. The GIVING part is also optional.
comm | in | Command string | |
Allowed: | String containing any valid table command | ||
handle | in | Table handle | |
Allowed: | Is meant for internal use only | ||
Default: | F | ||
tableserver | in | Table server to be used | |
Allowed: | Any tableserver | ||
Default: | defaulttableserver |
t := tablecommand('SELECT FROM table.in WHERE column1*column2 > 10 ORDERBY column1 GIVING table.out'); t.summary(); tablecommand('CALC FROM table.in CALC column1+2') tablecommand('CALC 1+2')The last example shows that it can be used as a desk calculator.