602SQL Documentation Index  



mixed wb_psql_execute( resource psql [, parameter values ] )


Identifier of a prepared SQL statement, result of the wb_psql_prepare function. Required parameter.
parameter values
If the prepared SQL statement contains parameters, you can pass IN parameters values this way and set the PHP variables for the OUT parameters that should contain the values after the SQL statement is processed. The parameters of the prepared SQL statement may also be passed using the wb_psql_send_param function for IN parameters and the wb_psql_get_out_param function for OUT parameters.


This function executes a prepared SQL statement, whose identifier (resource handle) was passed in the psql parameter.

If the SQL statement contains some parameters, but no IN parameter value was passed by calling the wb_psql_send_param function, the parameter values can be passed to this function. In this case you must add as many extra parameters as the number of actual parameters of the prepared SQL statement when calling this function. The parameters are passed in the same order, as in the SQL statement description.

You must pass a value that can be converted to the appropriate parameter type for each IN parameter. Also, for each OUT parameter, you must add a reference to the PHP variable that was initialized before the this function was executed (regardless of the variable type or value, this variable must exist). You must specify a reference to the PHP variable that contains the value that will be passed to the SQL Server and that will later store the returned value for each INOUT parameter.

A prepared SQL statement can be executed by this function many times and you may specify different parameter values each time.


The function returns FALSE if an error occurs. If the executed SQL statement opened a cursor, the function will return the identifier (resource handle), just like the wb_exec function. The identifier of the opened cursor may then be used when calling the wb_result function. If the executed SQL statement did not open a cursor, the function returns the number of records that were modified by the SQL statement (or 1).


Preparation and execution of a SQL statement with two parameters (the first is OUT, the second is IN). The OUT parameter value will be read into the PHP variable $name_var when the statement is complete (this variable must be initialized before SQL statement execution). The IN parameter value will be pass as a constant.

$psql=wb_psql_prepare($connection,"SELECT name INTO ? FROM Person WHERE ID=?");


Now we will execute the same SQL statement utilizing the PSQL function.

$psql=wb_psql_prepare($connection,"SELECT name INTO ? FROM Person WHERE ID=?");