Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
SET STOCKQTY = 0, WHCODE = ? WHERE ITMNO = 111
Example 6:
In this example, the dynamic parameter specification is specified in the insert value list of an INSERT
statement.
INSERT INTO STOCKS. STOCK (ITMNO, PRODUCT, STOCKQTY) VALUES(?, ?, ?)
USING clause
Use the USING clause to set values in the dynamic parameter specification of a prepared statement and to fetch the
execution results. Table: Uses of the USING clause and its specification format lists the uses of the USING clause and
its specification format.
[Table: Uses of the USING clause and its specification format]
With reference to the EXECUTE statements in Table: Uses of the USING clause and its specification format, the
USING clause used to set the value of the dynamic parameter specification is known as the parameter USING clause.
The USING clause used to fetch the execution results is known as the result USING clause.
There are two USING clause specification formats:
· Argument specification
· Specification of a variable name or the SQL descriptor name of an SQLDA structure variable
The first is referred to as a USING variable and the second as a USING descriptor.
The method for specifying the USING descriptor in the EXECUTE statement is shown below.
7.2 Modifying and Executing SQL Statements Dynamically
This section explains how to modify and execute SQL statements dynamically.
· Preparing SQL statements and manipulating the SQLDA structure
- Preparing and executing a dynamic SELECT statement (for SQLDA structure)
- Preparing and executing a dynamic single row SELECT statement (for SQLDA structure)
· Preparing SQL statements and manipulating the SQL descriptor area
- Preparing and executing a dynamic SELECT statement (for the SQL descriptor area)
- Preparing and executing a dynamic single row SELECT statement (for the SQL descriptor area)
7.2.1 Preparing SQL statements and manipulating the SQLDA structure
When data is fetched from a database using dynamic SQL, specify the target that will receive the execution results.
For the specified target to be able to receive the execution results, the select column list information must match the
attributes of the specified target. Matching is accomplished by fetching the select column list information from the
database to the SQLDA structure, then modifying the attributes. The SQLDA structure is positioned as shown in the
134