Dynamic SQL Format 1
Description
Use this format to execute a SQL statement that does not produce a
result set and does not require input parameters. You can use this
format to execute all forms of Data Definition Language (DDL).
Syntax
|
1 |
EXECUTE IMMEDIATE SQLStatement {USING TransactionObject} ; |
|
Parameter |
Description |
|---|---|
|
SQLStatement |
A string containing a valid SQL statement. The |
|
TransactionObject (optional) |
The name of the transaction object that identifies |
Examples
These statements create a database table named Trainees. The
statements use the string Mysql to store the CREATE statement.
For SAP ASE users
If you are connected to an ASE database, set AUTOCOMMIT to
true before executing the CREATE.
|
1 2 3 4 5 6 |
string MyASE MyASE = "CREATE TABLE Trainees "& +"(emp_id integer not null,"& +"emp_fname char(10) not null, "& +"emp_lname char(20) not null)" EXECUTE IMMEDIATE :MyASE ; |
These statements assume a transaction object named My_trans exists
and is connected:
|
1 2 3 4 |
string MyASE MyASE="INSERT INTO department Values (1234,"& +"'Purchasing',1234)" EXECUTE IMMEDIATE :MyASE USING My_trans ; |