Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> can I use a pl/sql cursor as subquery or in another cursor?

can I use a pl/sql cursor as subquery or in another cursor?

From: Peter Mutsaers <plm_at_gmx.li>
Date: 08 Nov 2002 17:18:46 +0100
Message-ID: <873cqcm3vd.fsf@muon.mutsaers.com>


Is it possible (in oracle 9i) to somehow use a cursor as subquery or in another cursor, in order to reuse parts of queries or to build complex queries modularly without resorting to dynamic sql?

I thought maybe oracle 9i new pipelined functions or cursor() operator might provide something, but I couldn't really figure out how.

I'd like something like this (in a package):

cursor abc(p1 in varchar2) is select a,b,c from tababc where d = p1;

cursor sumabc(p1 in varchar2) is

        select a,sum(c) from (abc(p1)) group by a;

It really drives me mad (being used to other computer languages where you can build using bottom-up or top-down breakdown) that I don't know how to avoid copying blocks of SQL for such cases. It must be possible in some way (I hope) to modularize sql statements???

-- 
Peter Mutsaers, Dübendorf, Switzerland.
Received on Fri Nov 08 2002 - 10:18:46 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US