Index...
Centrallix Documentation
|
6.1 SELECT Statements
SELECT statements
Here, the syntax is similar to normal SQL, except that the attribute names are preceded by a colon, and FROM sources are pathnames instead of in the usual SQL format of Database.Owner.Table. Here is a simple example of selecting a single constant value:
SELECT "Hello this is a SQL statement"
When a source is used, it is a pathname:
SELECT :name, :size from /samples
Using aliases on data sources is also possible:
SELECT :s:name, :s:size from /samples s
Attribute names may be quoted in order to permit them to contain special characters and spaces:
SELECT :"Account Number" from /datasource/tables/Account/rows
Attributes may also be renamed. This is particularly useful when using a constant or computed field:
SELECT filename=:name, filesize=:size from /samples
SELECT myConstant="this is a constant value"
Finally, SELECT * is permitted. However, be aware that in many circumstances the attributes will vary from one row to another in the result set. SELECT * does not automatically select the system attributes "name", "inner_type", "outer_type", "content_type", and "annotation". To select those, you can combine SELECT * with explicit columns.
SELECT * from /samples
SELECT :name, * from /samples
Limiting the Result Set Size
Centrallix can limit the number of rows returned in a SQL query either by using the "LIMIT" clause or by using the "set rowcount n" SQL clause, where n is the maximum number of rows to return.
Example:
SET ROWCOUNT 10 SELECT :name, * from /samples
The LIMIT clause (available in Centrallix 0.9.1 and up) is similar to the MySQL limit clause, and is placed somewhere in the SQL statement (normally at the very end). It has the form LIMIT [ start, ] count where start is an optional starting row number (first row is row 0), and count is the desired maximum number of rows to return. LIMIT N is equivalent to SET ROWCOUNT N.
Examples (the first one returns the first 10 rows, 1 through 10, and the second one returns rows 6 through 15):
SELECT :name, * from /samples LIMIT 10
SELECT :name, * from /samples LIMIT 5,10
Comments...
(none yet)
Add a Comment...
|