- Rongsen.Com.Cn 版权所有 2008-2010 京ICP备08007000号 京公海网安备11010802026356号 朝阳网安编号:110105199号
- 北京黑客防线网安工作室-黑客防线网安服务器维护基地为您提供专业的
服务器维护
,企业网站维护
,网站维护
服务 - (建议采用1024×768分辨率,以达到最佳视觉效果) Powered by 黑客防线网安 ©2009-2010 www.rongsen.com.cn
作者:黑客防线网安SQL维护基地 来源:黑客防线网安SQL维护基地 浏览次数:0 |
create table t1 ( col1 int)
DB20000I The SQL command completed successfully.
create table t2 ( col1 int )
DB20000I The SQL command completed successfully.
create procedure abc(in p int) begin insert into t1 values(p); end
DB20000I The SQL command completed successfully.
create trigger ins after insert on t2 referencing NEW as new for EACH ROW MODE
DB2SQL BEGIN ATOMIC values ( call_procedure('DB2INST1.ABC', char(new.col1 * 2),
'SAMPLE', 'DB2INST1', 'db2inst1') ); END
DB20000I The SQL command completed successfully.
insert into t2 values 20
DB20000I The SQL command completed successfully.
/* validate that the trigger has fired - it should update t1 */
select * from t1
COL1
-----------
40
1 record(s) selected.
下一个例子演示了在 UDF 中调用包含了两个参数的存储过程。在该例中,我们创建表( c ),带有两个输入参数的存储过程( abc )以及带有两个参数(parm1,parm2)的 UDF( udf_withcall )。当执行该 UDF 时,它将调用存储过程,然后,该存储过程会将由 UDF 传递给它的值插入表 c。对表 c 进行 select 将验证表 c 的内容以及存储过程是否执行成功。可以在“下载”小节中找到该脚本( udf_calls_proc.db2)的源代码。
create table c ( a int check (a <> 8), a1 int )
DB20000I The SQL command completed successfully.
create procedure abc(in p int, in p2 int) begin insert into c values(p,p2); end
DB20000I The SQL command completed successfully.
create function udf_withcall (parm1 int, parm2 int)
returns int
Language SQL
not deterministic
external action
return call_procedure('DB2INST1.ABC', char(parm1) ||','|| char(parm2), 'SAMPLE', 'DB2INST1', 'db2inst1'))
DB20000I The SQL command completed successfully.
select udf_withcall(30,40) from sysibm.sysdummy1
1
-----------
0
1 record(s) selected.
/* verify that the UDF has called the procedure and updated the table */
select * from c
A A1
----------- -----------
10 20
30 40
2 record(s) selected.
我要申请本站:N点 | 黑客防线官网 | |
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479 |