Reputation: 21
I am learning PL/SQL and I fired this query in the SQL Command Line
SELECT DNAME, CURSOR(SELECT SALARY, COMMISSSION_PCT
FROM EMP e
WHERE e.did=101)
from dept d
order by dname;
DNAME
--------------------------------------------------------------------------------
CURSOR(SELECTSALARY,
--------------------
AI
CURSOR STATEMENT : 2
CURSOR STATEMENT : 2
SALARY COMMISSSION_PCT
---------- ---------------
12000 .3
19000 .5
10000 .4
Nano_tech
CURSOR STATEMENT : 2
CURSOR STATEMENT : 2
Why am I getting CURSOR STATEMENT:2 while I have more than 2 tuples in the database? I know cursor acts like a pointer in PL/SQL but shouldn't it return 3 rather than 2?
Upvotes: 2
Views: 111
Reputation: 17924
The "2" in
CURSOR STATEMENT : 2
emitted by SQL*Developer is telling you that the cursor is in the 2nd column of your query output. It is NOT implying that the cursor's results contain 2 rows.
Replace your query with this:
SELECT DNAME, 'XXX' DUMMY, CURSOR(SELECT SALARY, COMMISSSION_PCT
FROM EMP e
WHERE e.did=101)
from dept d
order by dname;
And SQL*Developer will start emitting "CURSOR STATEMENT: 3".
Upvotes: 4