Home > Blogroll, sql > rename column_value

rename column_value

June 22nd, 2007


SQL> create or replace type t is 
 2  table of varchar2(12);
 3  /
Type created.

SQL> create or replace function f return t is 
 2  begin return t('foo'); end;
 3  /
Function created.

SQL> select * from table(f);

COLUMN_VALUE
------------
foo         

What is this column_value field? It is a pseudo-column. But you may want to have an user-defined column name.


SQL> create or replace type o is 
 2  object(BAR varchar2(12));
 3  /
Type created.

SQL> create or replace type t is 
 2  table of o;
 3  /
Type created.

SQL> create or replace function f return t is 
 2  begin return t(o('foo')); end;
 3  /
Function created.
SQL> select * from table(f);

BAR
------------
foo         

Blogroll, sql

  1. June 22nd, 2007 at 14:57 | #1

    what’s wrong with

    SQL> select t.column_value as bar from table(f) t;

    BAR
    ————
    foo

    ?

  2. June 22nd, 2007 at 17:06 | #2

    nothing wrong actually, I just wanted to show how to get an user-defined column name 8-)

  1. No trackbacks yet.