| Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
| Version 1.9 Build 1556 |
|
tab := table('mytable')
seltab1 := tab.query ('column1 > 0')
seltab2 := seltab1.query (query='column2>5',
sortlist='time',
columns='column1,column2',
name='result.tab')
The first command opens the table mytable.
The second command does a simple query resulting in a temporary
table. That temporary table is used in the next command resulting in
a persistent table. The latter function call is transformed to
the TaQL command:
It is possible to embed glish variables and expressions in a TaQL command using the syntax $variable and $(expression). A variable can be a standard numeric or string scalar or vector. It can also be a table tool. An expression has to result in a numeric or string scalar or vector. E.g
tab := table('mytable')
coldata := tab.getcol ('col');
colmean := sum(coldata) / len(coldata);
seltab1 := tab.query ('col > $colmean')
seltab2 := tab.query ('col > $(sum(coldata)/len(coldata))')
seltab3 := tab.query ('col > mean([SELECT col from $tab])')
These three queries give the same result.
myfunc := function() {
tab := table('mytable')
global coldata_in_myfunc;
coldata_in_myfunc := tab.getcol ('col');
seltab := tab.query ('col > $(sum(coldata)/len(coldata))')
symbol_delete ('coldata_in_myfunc');
}
The other function that can be used is tablecommand. The full TaQL command has to be given to that command. The result is a table tool. E.g.
t := tablecommand('select from GER.MS where ANTENNA1==1');
Table seltab1 = tableCommand
("select from mytable where column1>0");
Table seltab2 = tableCommand
("select column1,column2 from $1 where column2>5"
" orderby time giving result.tab", seltab1);
These examples do the same as the Glish ones shown above.
Int limit = 0;
Table tab ("mytable");
Table seltab = tab(tab.col("column1") > limit);
does the same as the first example shown above.
See classes Table,
TableExprNode, and
TableExprNodeSet
for more
information on how to construct a WHERE expression.