selecT Query

Top  Previous  Next

RelDBUpdateProcess and RelDBQueryProcess support a very special way of using the select query to retrieve information from database.

If you define the select word in your query statement exactly as selecT (all letters are in lowercase except the 'T' at the end) then it gets a special treatment from the processes.

When a selecT query is encountered, it is executed and the columns of the first result set record are transferred to the MScript symbols.

Warning!
A selecT query should produce a result set that has only one record. The record other than the first record are ignored.

Example 1:

The selecT statement below creates the "ROWID" field in the current Process Record that stores the last inserted row id.

INSERT INTO TABLE abc (F1, F2) VALUES(V1, V2);

selecT @@IDENTITY AS f:ROWID; 

 

Example 2:

The selecT statement below creates pool variables called MAXPRICE and MINPRICE that stores the maximum and minimum price values available in the products table.

selecT max(PRICE) as v:MAXPRICE, min(PRICE) as v:MINPRICE FROM products; 

 

Warning!
Depending on the database engine used, the column names that take place in the result set may be either all converted to uppercase or to lowercase. For example if the database is Oracle, as the result of the "selecT max(PRICE) as v:maxprice" definition the variable pool symbol becomes "MAXPRICE" .

In contrary to Oracle, If selecT max(PRICE) as v:MAXPRICE definition is used with PostgreSQL, the variable pool symbol name becomes "maxprice".