Centrallix - It's Different than what you Think
Home   |   Technology   |   Screen Shots   |   Download   |   Documentation   |   History   |   For Developers

Search...


Search For:

Index...


Centrallix Documentation

6.13 DECLARE Statements


DECLARE Statements

DECLARE statements allow you to create a temporary object or collection in the context of the current SQL query. They are mainly useful in the context of a multi-statement SQL query, for storing temporary results for use in later statements in the same query.

DECLARE OBJECT

DECLARE OBJECT objectname


where objectname is the name of the object you want to create. After the object is declared, its properties (all NULL by default) can be referenced in any expression, and its properties can be set by using a SELECT statement with assignments.

Example:

DECLARE OBJECT tmpobj;

SELECT :tmpobj:counter = 1;

SELECT :tmpobj:counter;

SELECT :tmpobj:counter = :tmpobj:counter + 1;

SELECT :tmpobj:counter


By default, declared objects have query scope and lifetime: they are valid only for the current multi-statement query. Declared objects can also have application scope, which means the object remains valid for as long as the application is active, and the object is in-scope for any query in the application which declares an object of that name with application scope.

DECLARE OBJECT objectname SCOPE APPLICATION


Note that such a declaration must exist in each query that uses the application-wide shared object.

DECLARE COLLECTION

Temporary collections (tables) can also be created with a DECLARE statement:

DECLARE COLLECTION collectionname


Such temporary collections can then be referenced as a data source in any SELECT, INSERT, UPDATE, or DELETE statement:

SELECT * FROM COLLECTION collectionname


Temporary collections do not have a predefined schema, keys, or indices. To avoid duplicates when inserting, use an ON DUPLICATE clause.

Temporary collections do not have predefined indexes. Indexes are automatically built based on the criteria used for querying the collection.

Temporary collections can also be of scope query or scope application:

DECLARE COLLECTION collectionname SCOPE APPLICATION


Comments...


(none yet)

Add a Comment...


Your Name:
Comment:


(c) 2001-2020 LightSys Technology Services, Inc. All trademarks are property of their respective owners.

Project Hosting Provided By:
Hosted by Sourceforge