浅谈IBM DB2数据库如何迁移问题(5)_SQL SERVER数据库_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

浅谈IBM DB2数据库如何迁移问题(5)

作者:黑客防线网安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.   crea...

 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.

 

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-10874-1.html
网站维护教程更新时间:2012-03-21 03:11:32  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer