本文介绍了如何在Oracle存储过程中将行手动添加到游标中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在存储过程中有一个游标.我想从查询中选择一些数据并将其插入游标,然后再次从另一个查询中选择一些数据并将该数据附加到同一游标中.

I have a cursor in stored procedure. I want to select some data from a query and insert that data into cursor, then again select some data from another query and append that data into the same cursor.

我该怎么做?

推荐答案

游标是SQL语句的只读句柄.游标没有数据.您不能将数据追加到游标.游标唯一可以做的就是获取下一行.

A cursor is a read-only handle for a SQL statement. A cursor has no data. You cannot append data to a cursor. The only thing you can do with a cursor is fetch the next row.

您可以将用于打开游标的SQL语句与两个不同的SQL语句(即

You can change the SQL statement that is used to open the cursor to UNION together the two different SQL statements, i.e.

OPEN rc FOR 
  SELECT <<column list>>
    FROM table1
  UNION ALL
  SELECT <<column list>>
    FROM table2;

RETURN rc;

这篇关于如何在Oracle存储过程中将行手动添加到游标中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 19:08