Top  >  Lycia reference  >  Querix 4GL  >  Statements  >  EXECUTE

EXECUTE

 

EXECUTE statement passes a previously prepared statement or a set of statements to the database server which executes them, if no errors are detected. This is another way to execute the prepared statements along with associating them with cursors. If the passed statement has one or more question mark placeholders, they are supplied with specific values before the execution.  When an SQL statement becomes prepared, it can be executed as often and as many times as it is necessary, until the FREE statement is performed.

 

The syntax of the EXECUTE statement is as follows:

 

EXECUTE prepared_stmt [INTO clause] [USING clause]

 

The prepared_stmt stands for the prepared statement identifier that must be defined in the PREPARE statement earlier in the source code text. It can also be a variable which contains the name of the prepared statement. The EXECUTE statement or the DECLARE cursor statement cannot refer to the statement identifier, if the program has already used the FREE statement to release the database server resources allocated to the specified prepared statement.

 

The EXECUTE statement can be applied to any prepared statement. However, if a prepared SELECT statement returns multiple rows, the data rows can be retrieved by means of the DECLARE, OPEN, and FETCH cursor statements.

 

The simple example of the EXECUTE statement application is given below:

 

PREPARE sel FROM "INSERT INTO goods VALUES ("string", 100)"

EXECUTE sel