设置用于创建结果集的变量。 [英] set variables to be used in creation of result set.

查看:44
本文介绍了设置用于创建结果集的变量。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法创建一个存储过程我可以使用
可以

DECLARE变量

然后使用这些变量设置这些变量一个选择的陈述 - 到此为止。

然后使用不同的陈述来生成结果集。


我一直试图这样做使用Cursor但是我得到一个错误

我在运行SQL语句后不能声明游标。


我不喜欢如果有另一种方式,则需要在光标中返回它。我只需要一个结果集。

解决方案

el ********* @ gmail.com 写道:

我想知道是否有是一种创建存储过程的方法,我可以使用选择的语句设置这些变量然后使用选择的语句来设置这些变量 - 然后使用不同的语句生成一个结果集。

我一直在尝试使用Cursor执行此操作但是我收到一个错误
在SQL语句被删除后我无法声明游标跑。


将DECLARE CURSOR语句包装在自己的BEGIN ... END块中。

如果有,我不需要将它返回到光标中是另一种方式。我只需要一个结果集。




结果集和游标相互关联。


- -

Knut Stolze

DB2信息集成开发

IBM德国


谢谢。


Knut Stolze< st **** @ de.ibm.com>写道:

el ********* @ gmail.com 写道:

我想知道是否有办法创建一个存储过程,我可以通过DECLARE变量然后使用选择语句设置这些变量
- - 到目前为止工作。
然后使用不同的语句来生成结果集。

我一直在尝试使用Cursor执行此操作但是我得到一个错误



将DECLARE CURSOR语句包装在自己的BEGIN ... END块中。




这是在v8中添加的吗?


我得到了......第20行COL 1嵌套的化合物声明不允许
当我尝试使用时,
作为构建错误,但我正在使用v7。


-

J. Moreno


I was wondering if there is a way to create a stored procedure that I
can
DECLARE Variables
then set these variables using a select statment -- up to here works.
then use a different statement to generate a result set.

I''ve been trying to do this with using a Cursor but I get an error that
I can''t DECLARE a cursor after a SQL statement has been run.

I don''t need it to be returned in a Cursor if there is another way. I
just need a result set.

解决方案

el*********@gmail.com wrote:

I was wondering if there is a way to create a stored procedure that I
can
DECLARE Variables
then set these variables using a select statment -- up to here works.
then use a different statement to generate a result set.

I''ve been trying to do this with using a Cursor but I get an error that
I can''t DECLARE a cursor after a SQL statement has been run.
Wrap the DECLARE CURSOR statement in its own BEGIN ... END block.
I don''t need it to be returned in a Cursor if there is another way. I
just need a result set.



Result sets and cursors are tied to each other.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany


thank you.


Knut Stolze <st****@de.ibm.com> wrote:

el*********@gmail.com wrote:

I was wondering if there is a way to create a stored procedure that I
can DECLARE Variables then set these variables using a select statment
-- up to here works.
then use a different statement to generate a result set.

I''ve been trying to do this with using a Cursor but I get an error that
I can''t DECLARE a cursor after a SQL statement has been run.



Wrap the DECLARE CURSOR statement in its own BEGIN ... END block.



Was this added in v8?

I got "...LINE 20 COL 1 NESTED COMPOUND STATEMENTS NOT ALLOWED"
as a build error when I tried that, but I''m using v7.

--
J. Moreno


这篇关于设置用于创建结果集的变量。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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