PREPARED

 

PREPARED data type is an object data type which stores a prepared SQL statement. It acts similar to a statement identifier used in the PREPARE statement, but has a number of advantages, if compared to it.

 

PREPARED variables can be passed to functions and returned by them. It can be declared as any other variable of simple data type, thus it can be local, module or global. Thus while the prepared statement identifier used in the PREPARE statement has the module scope of reference only, a PREPARED variable can have any scope of reference, depending on the place where it is declared.

 

You shouldn't assign values to a PREPARED variable using the LET statement. This variable should be used with the special methods, which allow you to specify the prepared statement and then to use it in your program. A method is called in the same way as a function, but it need to be prefixed with the PREPARED variable and separated from it by a full stop, i.e.:

 

variable.Method()

 

Here are the methods used with the PREPARED data type:

 

execute()

executes  prepared  statements associated with a variable and returns output values, if any

free()

frees the memory allocated to the prepared statement and makes it possible to use the PREPARED variable to prepare SQL statements

getName()

retrieves the name of a prepared statement

getStatement()

returns the text of the SQL statement which have been prepared using the prepare() method

isNative()

verifies whether the SQL statement was prepared natively

prepare()

initializes a variable of the PREPARED data type and prepares an SQL statement for the execution in the RDBMS

setParameters()

supplies values for substituting placeholders, if any

setResults()

changes the output values produced by the prepared statement