If a prepared statement fails to access any rows when it executes, the database server returns the SQLCODE value of zero (0).
For a multistatement prepared object, however, if any statement in the following list fails to access rows, the returned SQLCODE value is SQLNOTFOUND ( = 100):
In an ANSI-compliant database, if you prepare and execute any of the statements in the preceding list, and no rows are returned, the returned SQLCODE value is SQLNOTFOUND ( = 100).
Use the USING clause to specify the values that are to replace question-mark ( ? ) placeholders in the prepared statement. Providing values in the EXECUTE statement that replace the question-mark ( ? ) placeholders in the prepared statement is sometimes called parameterizing the prepared statement.
USING Clause: .-,-----------------------------------------------. V | |--USING--+---parameter_var--+------------------------------+-+-+--| | | (1) | | | '-+-------- :-+--indicator_var-' | | '-INDICATOR-' | +-SQL DESCRIPTOR--+-descriptor_var-+------------------+ | '-'descriptor'---' | '-DESCRIPTOR--sqlda_pointer---------------------------'
Element | Description | Restrictions | Syntax |
---|---|---|---|
descriptor | Quoted string that identifies a system-descriptor area | System-descriptor area must already be allocated. Use single ( ' ) quotation marks. | Quoted String |
descriptor_var | Host variable that identifies a system-descriptor area | System-descriptor area must already be allocated | Language specific |
indicator_var | Host variable that receives a return code if corresponding parameter_var is NULL value, or if truncation occurs | Cannot be DATETIME or INTERVAL data type | Language specific |
parameter_var | Host variable whose contents replace a question-mark ( ? ) placeholder in a prepared statement | Must be a character data type | Language specific |
sqlda_pointer | Pointer to an sqlda structure that defines data type and memory location of values to replace question-mark ( ? ) placeholder in a prepared object | Cannot begin with a dollar sign ( $ ) or a colon ( : ). An sqlda structure is required with dynamic SQL | DESCRIBE INPUT |
This closely resembles the syntax of the INTO Clause.
If you know the number of parameters to be supplied at runtime and their data types, you can define the parameters that are needed by the EXECUTE statement as host variables in your program.
If you do not know the number of parameters to be supplied at runtime or their data types, you can associate input values from a system-descriptor area or an sqlda structure. Both of these descriptor structures describe the data type and memory location of one or more values to replace question-mark ( ? ) placeholders.
Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]