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
Whenever we use JOIN in a cursor on two or more tables (ORDERS and TRANSACTIONS in this case) a temporary table is generated in the virtual memory. However, since this is a temporary table we can fetch data from this table but it is not possible to update this table.
You cant join a cursor to a table. cursor is a SQL work area where instruction to execute a SQL is processed. 1.
A record is similar to a table row, can hold one value for each column at a time. cursors are like "tables" they may hold multiple rows (records if you will).
To execute a multi-row query, Oracle opens an unnamed work area that stores processing information. A cursor lets you name the work area, access the information, and process the rows individually.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With