最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
动态SQL四种类型的语句格式
时间:2022-07-02 09:45:49 编辑:袖梨 来源:一聚教程网
1.Dynamic SQL Format 1
EXECUTE IMMEDIATE SQLStatement {USING TransactionObject} ;
eg:
string Mysql
Mysql = "CREATE TABLE Employee "&
"(emp_id integer not null,"&
"dept_id integer not null, "&
"emp_fname char(10) not null, "&
"emp_lname char(20) not null)"
EXECUTE IMMEDIATE :Mysql ;
2.Dynamic SQL Format 2
PREPARE DynamicStagingArea FROM SQLStatement {USING TransactionObject} ;
EXECUTE DynamicStagingArea USING {ParameterList} ;
eg:
INT Emp_id_var = 56
PREPARE SQLSA
FROM "DELETE FROM employee WHERE emp_id=?" ;
EXECUTE SQLSA USING :Emp_id_var ;
3.Dynamic SQL Format 3
DECLARE Cursor | Procedure DYNAMIC CURSOR | PROCEDURE FOR DynamicStagingArea ;
PREPARE DynamicStagingArea FROM SQLStatement {USING TransactionObject} ;
OPEN DYNAMIC Cursor {USING ParameterList} ;
EXECUTE DYNAMIC Procedure {USING ParameterList} ;
FETCH Cursor | Procedure INTO HostVariableList ;
CLOSE Cursor | Procedure ;
eg:
integer Emp_id_var
DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA ;
PREPARE SQLSA FROM "SELECT emp_id FROM employee" ;
OPEN DYNAMIC my_cursor ;
FETCH my_cursor INTO :Emp_id_var ;
CLOSE my_cursor ;
4.Dynamic SQL Format 4
DECLARE Cursor | Procedure DYNAMIC CURSOR | PROCEDURE FOR DynamicStagingArea ;
PREPARE DynamicStagingArea FROM SQLStatement {USING TransactionObject} ;
DESCRIBE DynamicStagingArea INTO DynamicDescriptionArea ;
OPEN DYNAMIC Cursor | Procedure USING DESCRIPTOR DynamicDescriptionArea ;
EXECUTE DYNAMIC Cursor | Procedure USING DESCRIPTOR DynamicDescriptionArea ;
FETCH Cursor | Procedure USING DESCRIPTOR DynamicDescriptionArea ;
CLOSE Cursor | Procedure ;
eg:
string Stringvar, Sqlstatement
integer Intvar
EXECUTE IMMEDIATE SQLStatement {USING TransactionObject} ;
eg:
string Mysql
Mysql = "CREATE TABLE Employee "&
"(emp_id integer not null,"&
"dept_id integer not null, "&
"emp_fname char(10) not null, "&
"emp_lname char(20) not null)"
EXECUTE IMMEDIATE :Mysql ;
2.Dynamic SQL Format 2
PREPARE DynamicStagingArea FROM SQLStatement {USING TransactionObject} ;
EXECUTE DynamicStagingArea USING {ParameterList} ;
eg:
INT Emp_id_var = 56
PREPARE SQLSA
FROM "DELETE FROM employee WHERE emp_id=?" ;
EXECUTE SQLSA USING :Emp_id_var ;
3.Dynamic SQL Format 3
DECLARE Cursor | Procedure DYNAMIC CURSOR | PROCEDURE FOR DynamicStagingArea ;
PREPARE DynamicStagingArea FROM SQLStatement {USING TransactionObject} ;
OPEN DYNAMIC Cursor {USING ParameterList} ;
EXECUTE DYNAMIC Procedure {USING ParameterList} ;
FETCH Cursor | Procedure INTO HostVariableList ;
CLOSE Cursor | Procedure ;
eg:
integer Emp_id_var
DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA ;
PREPARE SQLSA FROM "SELECT emp_id FROM employee" ;
OPEN DYNAMIC my_cursor ;
FETCH my_cursor INTO :Emp_id_var ;
CLOSE my_cursor ;
4.Dynamic SQL Format 4
DECLARE Cursor | Procedure DYNAMIC CURSOR | PROCEDURE FOR DynamicStagingArea ;
PREPARE DynamicStagingArea FROM SQLStatement {USING TransactionObject} ;
DESCRIBE DynamicStagingArea INTO DynamicDescriptionArea ;
OPEN DYNAMIC Cursor | Procedure USING DESCRIPTOR DynamicDescriptionArea ;
EXECUTE DYNAMIC Cursor | Procedure USING DESCRIPTOR DynamicDescriptionArea ;
FETCH Cursor | Procedure USING DESCRIPTOR DynamicDescriptionArea ;
CLOSE Cursor | Procedure ;
eg:
string Stringvar, Sqlstatement
integer Intvar
相关文章
- 无期迷途哈梅尔依偎涟漪怎么样 11-25
- 剑与远征折翼苍空攻略 11-25
- 光遇11.25每日任务怎么做 光遇11月25日每日任务做法攻略 11-25
- 光遇11.25季节蜡烛在哪里 光遇11月25日季节蜡烛位置攻略 11-25
- 崩坏星穹铁道2.7前瞻有什么活动 崩铁2.7版本前瞻新增内容介绍 11-25
- “十月朝,糍粑碌碌烧”是说哪个习俗 蚂蚁庄园11月22日答案最新 11-25