Figure 13-1
This illustration helps you choose the right method for using dynamic SQL. Is the SQL statement a query? If the answer is no, does it contain input host variables? If the answer is no, will it be executed repeatedly? If the answer is no, use method 1. If the SQL statement will be executed repeatedly, use method 2. If the SQL statement is not a query but does contain input host variables, does it also contain an unknown number of input host variables? If the answer is no, use method 2. If the answer is yes, use method 4. If the SQL statement is a query, does its select list contain an unknown number of items? If the answer is yes, use method 4. If the answer is no, does it contain an unknown number of input host variables? If the answer is no, use method 3. If the answer is yes, use method 4.