PREPARE

PREPARE statement is used to prepare an execution plan according to which SQL statements will be executed in a 4GL program.

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 this way:

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.

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.