"Overview of Dynamic SQL". When the preparable statement is the INSERT statement, UPDATE statement
(searched), DELETE statement (searched), UPDATE statement (positioned), or DELETE statement (positioned), the
dynamic parameter specification cannot be specified.
If an SQL statement variable contains an UPDATE statement (positioned) or a DELETE statement (positioned), the
corresponding cursor must be opened beforehand. Also, the specified cursor must be a dynamic cursor.
The following is an example of specifying an EXECUTE IMMEDIATE statement.
Example:
The rows for which STOCKQTY is "0" are deleted from the STOCK table.
7.5 Changing Database Names and Omitted Schema Name
s
This section explains how to change database names and omitted schema names in prepared statements to be
executed by dynamic SQL in an application program.
7.5.1 Changing database names
The database name for a prepared statement executed by dynamic SQL is the database name furnished by the
connection. The furnished database name is the name of the SQL server name specified in the CONNECT statement.
This database name can be changed in the application program. The database name specified in the SET CATALOG
statement is for the prepared statements of PREPARE and EXECUTE IMMEDIATE statements. The changed
database name is valid until the session terminates.
The following is an example of specifying the SET CATALOG statement:
Example:
In this example, the name of the data base is changed to "RDBDB2".
7.5.2 Changing schema names
For more information on omitting schema name qualifiers when a table declaration is specified, see 6.10 "Omitting
Schema Names". A schema name based on a table declaration cannot be omitted from the table name of a prepared
statement executed by dynamic SQL. If the schema name is omitted from the table name of a prepared statement, the
login name specified in the CONNECT statement becomes the schema name. The omitted schema name can be
changed in the application program. The schema name specified in the SET SCHEMA statement is for the prepared
statements of PREPARE and EXECUTE IMMEDIATE statements. The changed schema name is valid until the
session terminates.
The following is an example of specifying the SET SCHEMA statement:
190