Re: variable select list in a cursor

From: Lun Wing San (Oracle) <"Lun>
Date: 1996/11/21
Message-ID: <32953C56.4140_at_qrcsun.qrc.org>#1/1


Tansel Ozkan wrote:
>
> Is there any way one can have a variable list of fields in a cursor?
>
> e.g.
>
> company table have these fields:
> company_name, revenue_jan,revenue_feb .... revenue_dec;
>
> 1)
> CURSOR mycursor is
> SELECT revenue_mar,revenue_apr
> FROM company
> WHERE company_name = 'AT&T';
> 2)
> CURSOR mycursor is
> SELECT revenue_sep,revenue_oct
> FROM company
> WHERE company_name = 'AT&T';
>
> I want to be able to define one cursor and specify the fields
> corresponding to different months. If you look at the above example, I
> want to be able to open the cursor 'mycursor' with any field combination
> I want ( revenue_mar, revenue-apr or revenue_sep, revenue-oct)

  You can use dynamic SQL to implement it. Please refer to DBMS_SQL package.

---
Name   : Lun Wing San
Title  : Oracle Application Developer of Hong Kong Productivity Council
         Oracle Database Administrator and System Administrator of QRC
Phone  : (852)27885841
Received on Thu Nov 21 1996 - 00:00:00 CET

Original text of this message