oracle 在oracle中加入游标或记录集

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4121092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:52:25  来源:igfitidea点击:

Join a cursor or record set in oracle

sqloraclejoincursor

提问by Shah Al

I have good experience in sybase and have started looking into oracle in free time. Most of the sybase procedures that i have worked with have temp tables and it makes sense to join two or more temp tables get a result set.

我在 sybase 方面有很好的经验,并开始在空闲时间研究 oracle。我使用过的大多数 sybase 过程都有临时表,连接两个或多个临时表得到一个结果集是有意义的。

Question: Is there a way to join two or more cursors like a logical table.

问题:有没有办法像逻辑表一样连接两个或多个游标。

Something like:

就像是:

SELECT c1.id, 
       c2.name 
  FROM cursorEmp c1, 
       CursorDept c2 
 WHERE c1.DeptId = c2.DeptId

回答by Justin Cave

You cannot join two cursors, no.

你不能加入两个游标,不。

You could, of course, combine the two underlying queries, i.e.

当然,您可以组合两个底层查询,即

SELECT c1.id,
       c2.name
  FROM (SELECT * FROM emp WHERE ename = 'KING') c1,
       (SELECT * FROM dept WHERE dname = 'ACCOUNTING') c2
 WHERE c1.DeptID = c2.DeptID

In Oracle, since readers do not block writers (and vice versa), it is very rarely necessary to use temporary tables. You would normally just query the underlying tables using views as appropriate to provide appropriate levels of abstraction.

在 Oracle 中,由于读取器不会阻塞写入器(反之亦然),因此很少需要使用临时表。您通常只使用视图查询基础表,以提供适当的抽象级别。

回答by Shah Al

Oracle does have its own version of temporary tables (permanent structures with temporary data stored for the duration of either a transaction or a session) - you could consider using those, although (as Justin suggested) you could also combine the two underlying queries.

Oracle 确实有自己版本的临时表(在事务或会话期间存储临时数据的永久结构) - 您可以考虑使用它们,尽管(如 Justin 建议的)您也可以组合两个底层查询。