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

Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL question

Re: PL/SQL question

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Fri, 16 Sep 2005 13:05:56 -0400
Message-ID: <KcqdnfVxSJHqZrfenZ2dnUVZ_sidnZ2d@comcast.com>

"Rolf Johnny van der Zwart" <blackpit_at_wanadoo.nl> wrote in message news:j1qli156s3h7efp19tlkd0ui19i8vkdpe1_at_4ax.com...
> Hello,
>
> Is it possible to use a variable in the select statement which holds
> the column I want to select?
>
> So:
>
> declare
> range number;
> column_name varchar2(10);
> begin
> for range in 1..48 loop
> column_name := halfhour||range;
> select column_name from some_table;
> end loop;
> end;
> /
>
>
> I need this to select a column halfhour1 until halfhour48, so I need
> to give the number at the end of the column_name.
>
> Any idea's?
>
>
> Rolf.

  1. you'll need to use dynamic SQL ... look into EXECUTE IMMEDIATE
  2. you may want to revisit you design. having columns halfhour1 thru halfhour48 is denormalized and bad design... if these were normalized you wouldn't have this type of processing issue

++ mcs Received on Fri Sep 16 2005 - 12:05:56 CDT

Original text of this message

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