编写复合/复杂的sql [英] writing compound/complex sql

查看:74
本文介绍了编写复合/复杂的sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


是否可以在没有存储过程的情况下编写复合sql或

触发器。

我可以运行在db2的指挥中心。


问候,

jagdip singh

解决方案

db2admin写道:


hello,


是否可以在没有存储过程的情况下编写复合sql或

触发器。

我可以在db2的命令中心运行。



是的,你可以。


-

Knut Stolze

DB2 z / OS管理员启用

IBM德国


3月12日,下午1:52,db2admin < jag ... @ gmail.comwrote:


hello,


是否可以在不存储的情况下编写复合sql程序或

触发器。

我可以在db2的命令中心运行。


问候,

jagdip singh



您可以使用命令编辑器或右键单击数据库并选择

查询选项卡。

你可以在任何一个地方写复杂的sql。


3月12日,上午11:05,dunleav1 < j ... @ dunleavy w:$:


3月12日下午1:52,db2admin < jag ... @ gmail.comwrote:


hello,


is可以在没有存储过程的情况下编写复合sql或

触发器。

我可以在db2的命令中心运行。


问候,

jagdip singh



你可以使用命令编辑器或右键单击数据库并选择

查询选项卡。

您可以在任何一个地方编写复杂的sql。



Jagdip。


我认为你可能要问的最终是BEGIN

ATOMIC块,有点类似于
Oracle中的匿名块,如果这对你有帮助的话。在DB2中,这种结构被称为

内联SQL PL。


这里是一个简单的例子(将10000个随机整数插入表中):


BEGIN ATOMIC

DECLARE C_CNTR INTEGER DEFAULT 0; -

WHILE C_CNTR< 10000 DO

插入IX_TEST(C1)值(CAST((RAND()* 100)AS INTEGER)); -

SET C_CNTR = C_CNTR + 1; - -

END WHILE; -

END;


您可以在内联SQL PL中做很多事情,你可以做在SP中,

如声明变量,循环和游标FOR LOOP,但是有几件事你不能做,比如声明异常处理程序,DDL ,

和COMMIT / ROLLBACK。


HTH,


- 杰夫


hello,

is it possible to write compound sql without stored procedure or
trigger.
can i just run in command center of db2.

regards,
jagdip singh

解决方案

db2admin wrote:

hello,

is it possible to write compound sql without stored procedure or
trigger.
can i just run in command center of db2.

Yes, you can.

--
Knut Stolze
DB2 z/OS Admin Enablement
IBM Germany


On Mar 12, 1:52 pm, "db2admin" <jag...@gmail.comwrote:

hello,

is it possible to write compound sql without stored procedure or
trigger.
can i just run in command center of db2.

regards,
jagdip singh

You can use the command editor or right click on database and pick
query tab.
You can write complex sql in either place.


On Mar 12, 11:05 am, "dunleav1" <j...@dunleavyenterprises.comwrote:

On Mar 12, 1:52 pm, "db2admin" <jag...@gmail.comwrote:

hello,

is it possible to write compound sql without stored procedure or
trigger.
can i just run in command center of db2.

regards,
jagdip singh


You can use the command editor or right click on database and pick
query tab.
You can write complex sql in either place.

Hi, Jagdip.

I think that what you might be asking about is ultimately the BEGIN
ATOMIC block, which is a bit analogous to an anonymous block in
Oracle, if that''s helpful to you. In DB2 such constructs are known as
inline SQL PL.

Here''s a trivial example (inserts 10000 random integers into a table):

BEGIN ATOMIC
DECLARE C_CNTR INTEGER DEFAULT 0;--
WHILE C_CNTR < 10000 DO
INSERT INTO IX_TEST (C1) VALUES (CAST((RAND()*100) AS INTEGER));--
SET C_CNTR = C_CNTR + 1;--
END WHILE;--
END;

You can do lots of things in inline SQL PL that you can do in SPs,
such as declare variables, loops, and cursor FOR LOOPs, but there are
several things you can''t do, such as declare exception handlers, DDL,
and COMMIT/ROLLBACK.

HTH,

--Jeff


这篇关于编写复合/复杂的sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆