Dynamic SQL Format 1 SQL statement
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 <span>SQLStatement</span> <br> {USING <span>TransactionObject</span>} ; |
|
Parameter |
Description |
|---|---|
|
SQLStatement |
A string containing a valid SQL statement. The string can be |
|
TransactionObject (optional) |
The name of the transaction object that |
Examples
These statements create a database table named Trainees.
The statements use the string Mysql to store
the CREATE statement.
For Sybase ASE users
If you are connected to an ASE database, set AUTOCOMMIT to true before executing
the CREATE.
|
1 |
string MyASE |
|
1 |
MyASE = "CREATE TABLE Trainees "& |
|
1 |
+"(emp_id integer not null,"& |
|
1 |
+"emp_fname char(10) not null, "& |
|
1 |
+"emp_lname char(20) not null)" |
|
1 |
EXECUTE IMMEDIATE :MyASE ; |
These statements assume a transaction object named My_trans exists
and is connected:
|
1 |
string MyASE |
|
1 |
MyASE="INSERT INTO department Values (1234,"&  |
|
1 |
       +"'Purchasing',1234)" |
|
1 |
EXECUTE IMMEDIATE :MyASE USING My_trans ; |