Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: tablecopy - Function Up: table - Module Previous: tabletest - Function


tablecommand - Function



Package utility
Module table


Execute a table command


Synopsis
tablecommand(comm, handle, tableserver)


Description
This function makes it possible to do selection and sorting on tables using an SQL-like grammar. It returns a table tool which can be used as any other table tool.
It is also possible to do a calculation on a table which returns the result as a record, vector, or scalar (see function calc).

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.



Arguments

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


Returns
table tool, record, vector, or scalar


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





next up previous contents index
Next: tablecopy - Function Up: table - Module Previous: tabletest - Function   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15