在oracle中加入游标或记录集

发布于 2024-10-01 06:02:32 字数 286 浏览 0 评论 0原文

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

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

类似:

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

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遇见了你 2024-10-08 06:02:32

你不能连接两个游标,不。

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

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

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

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.

甜扑 2024-10-08 06:02:32

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文