设置用于创建结果集的变量。

编程入门 行业动态 更新时间:2024-10-28 20:22:17
本文介绍了设置用于创建结果集的变量。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道是否有办法创建一个存储过程我可以使用可以 DECLARE变量 然后使用这些变量设置这些变量一个选择的陈述 - 到此为止。 然后使用不同的陈述来生成结果集。 我一直试图这样做使用Cursor但是我得到一个错误 我在运行SQL语句后不能声明游标。 我不喜欢如果有另一种方式,则需要在光标中返回它。我只需要一个结果集。

解决方案

el ********* @ gmail 写道:

我想知道是否有是一种创建存储过程的方法,我可以使用选择的语句设置这些变量然后使用选择的语句来设置这些变量 - 然后使用不同的语句生成一个结果集。 我一直在尝试使用Cursor执行此操作但是我收到一个错误在SQL语句被删除后我无法声明游标跑。 将DECLARE CURSOR语句包装在自己的BEGIN ... END块中。 如果有,我不需要将它返回到光标中是另一种方式。我只需要一个结果集。

结果集和游标相互关联。 - - Knut Stolze DB2信息集成开发 IBM德国

谢谢。

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

el ********* @ gmail 写道:

我想知道是否有办法创建一个存储过程,我可以通过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 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> wrote:

el*********@gmail 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

更多推荐

设置用于创建结果集的变量。

本文发布于:2023-10-27 18:18:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534157.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!