To meet your needs, we constantly work to improve Querix products.
This means that Lycia documentation is developing as well.
In case you have found a certain dissonance between the provided information and the actual behavior of Lycia 3 and/or your applications, please, let us know about this via documentation@querix.com so that we can introduce the necessary changes to our documentation.
Thank you for your attention and cooperation.
PREPARE statement is used to prepare an execution plan according to which SQL statements will be executed in a 4GL program.
Element |
Description |
Identifier |
SQL Statement identifier, this must be unique among the declared cursors and other prepared statements |
Character Expression |
A character expression which returns the text of one or more SQL statements to be prepared |
The PREPARE statement brings together the text and creates an SQL statement out of it at the runtime. The dynamic SQL is assembled in the following way:
The text of the SQL statement is specified in the PREPARE statement as a character expression. The text can contain the question marks (?) which represent the user-supplied values which should be specified at runtime. This text can be either in the form of
a quoted character string
a variable of character type
The prepared SQL statement can be executed by means of the EXECUTE or OPEN statement, the input values can be supplied by the USING clause. A prepared statement can be executed unlimited number of times
After you have used the prepared statement and are sure you will not need it again, you can use the FREE statement to deallocate the resources used for the PREPARE statement.
A 4GL variable cannot be referenced within the PREPARE statement. To do so, use the SQL … END SQL statement instead.
Number of prepared objects in a program is not limited by 4GL. It is only limited by the free memory on your system. A prepared object can include cursor declarations (that include SELECT, EXECUTE PROCEDURE, or INSERT statements) and statements identifiers.
Prepared statements can be used to improve the efficiency of your 4GL program. For example, if you place use the INSERT or UPDATE statement in a WHILE loop, the statement is processed each time the loop is executed. This leads to overhead and 4GL spends much time for processing these loops. If you place the prepared INSERT or UPDATE statement outside the loop and then execute it within the loop, the statement will be processed only once and then the result of its execution will be used in the WHILE loop. This will speed up the execution of the loop and eliminate the overhead.