|
wb_psql_prepare | 'Prepared' SQL Functions | wb_psql_param_count |
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=?"); $name_var=null; wb_psql_execute($psql,$name_var,123); wb_psql_execute($psql,$name_var,456);
Now we will execute the same SQL statement utilizing the PSQL function.
$psql=wb_psql_prepare($connection,"SELECT name INTO ? FROM Person WHERE ID=?"); wb_psql_send_param($psql,1,123); wb_psql_execute($psql); $name_var=wb_psql_get_out_param($psql,0); wb_psql_send_param($psql,1,456); wb_psql_execute($psql); $name_var=wb_psql_get_out_param($psql,0);
wb_psql_prepare | 'Prepared' SQL Functions | wb_psql_param_count |