Problem in SQL with CURSOR( ) ,Why the CURSOR did not work?

hi All:
I have a problem in SQL with CURSOR.
The data is as the attachments.
Here is the SQL statement as follow:
SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
FROM F3102 X
WHERE X.IGDOCO=A.WADOCO
AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
WHERE A.WADOCO='10004'
The statement above returns records as follow:
WADC WADOCO IGCOST DETAIL
WO 10004 A1 CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
IGLITM
1KV90CPG2
1KV90CPG2
1KV90CPG2
But, after I add one statement in the subquery, there is no record returned from CURSOR.
Here is the SQL statement:
SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
FROM F3102 X
WHERE X.IGDOCO=A.WADOCO
AND X.IGCOST=B.IGCOST
AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
WHERE A.WADOCO='10004'
The statement above returns records as follow:
WADC WADOCO IGCOST DETAIL
WO 10004 A1 CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
no rows selected
Why the CURSOR did not work?
The database version is Oracle Database 10g Release 10.2.0.4.0 - 64bit Production.
F3102 DATA:
IGDOCO     IGDCTO     IGLITM     IGCOST
10004     WO     1KV90CPG2      A1
10004     WO     1KV90CPG2      B1
10004     WO     1KV90CPG2      C3
10004     WO     1KV90CPG2      D1
F4801 DATA:
WADCTO     WADOCO
WO     10004
Edited by: user2319139 on 2010/3/2 上午 1:17
Edited by: user2319139 on 2010/3/2 上午 1:20

Why this structure and not a join?
The cursor() function returns a cursor handle that needs to be processed - in other words, the client needs to fetch data from it. The Oracle® Database SQL Reference+ (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions005.htm#i1035107) describes it as being equivalent to a ref cursor handle.
Thus why are you creating ref cursor handles as a column in a SQL projection - where each row will have a "+nested+" ref cursor handle to process. What problem are you attempting to hack solve this way?

Similar Messages

Maybe you are looking for