Session Statement

A Statement is created from a Session object and is not tied to a particular table object. A Session statement is created by using a SQL SELECT string and the table for the query is determined by parsing the SELECT string.

The SQL SELECT string supported has the form:
SELECT <select list> <from clause> [<where clause>] [<group by clause>] [<order by clause>] [<limit clause>]

For a complete description of each component of the SELECT syntax, see the subsections under The SQL SELECT Statement.

For more information about statements, see Statement.

Advantages of a Session Statement over a Table Iterator

Using a Session statement to execute SQL SELECT statements has the following advantages over using a table iterator:
  • You do not have to create a Table object before you can query a table.
  • The same query can be run multiple times using a single Statement object.
  • To aid with data security, you can use parameters to decouple the query from the data values used in the query.
  • Parameters can be used to vary the result of your query each time it is run.
  • You can specify a subset of the columns of a table to be returned in the rows of the query results.
  • Aggregation functions can be applied to the query results.
  • A GROUP BY clause can be used to aggregate the results of a query.
  • An ORDER BY clause can be used to sort the results of a query.
  • A LIMIT clause can be used to set an upper bound to the number of rows a query can return.