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 -> Re: oracle column alias

Re: oracle column alias

From: Gocha Mchedlishvili <gocham_at_cwix.com>
Date: Thu, 06 May 1999 02:30:10 GMT
Message-ID: <S87Y2.332$Fl4.24051@news.cwix.com>


I would use procedure to do this
something like this

create or replace procedure cr_view (sViewName VARCHAR2) is
begin
declare
iCr INTEGER;
sStr VARCHAR(255);
sMonth VARCHAR2(30);
begin

    iCr:=DBMS_SQL.OPEN_CURSOR;
    select to_char(sysdate,'MONTH') INTO sMonth from dual;     sStr:='CREATE VIEW ' || sViewName || ' as select field1, field2 as ' || sMonth || ' from table1' ;

    DBMS_SQL.PARSE(iCr,sStr,DBMS_SQL.NATIVE);     DBMS_SQL.CLOSE_CURSOR(iCr);
end;
end;

Gocha

weixingchen_at_my-dejanews.com wrote in message <7gq7s1$5ap$1_at_nnrp1.deja.com>...
>Hi everyone,
> I am trying to create a view with column name alias as the name of the
>current month, for example, a query of one such view will generate data
like
>
> column1 May
> ------- ---
> Dallas 54
> St. Louis 30
>
>It seems that I can't use to_char(sysdate, ...) function for column alias.
>Can anyone help with this.
>
>
>Thanks in advance
>
>Wayne
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Received on Wed May 05 1999 - 21:30:10 CDT

Original text of this message

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