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: Question about CHAR return from function

Re: Question about CHAR return from function

From: Mark D Powell <mark.powell_at_eds.com>
Date: 27 Aug 2002 11:47:50 -0700
Message-ID: <178d2795.0208271047.3244cfa8@posting.google.com>


"Lloyd Sheen" <sqlguy_at_hotmail.com> wrote in message news:<0eMa9.19890$6m61.16811_at_news04.bloor.is.net.cable.rogers.com>...
> Just a small question. I am writing a function but it seems impossible to
> put a size to the return of a CHAR. I can use VARCHAR2 but would like to
> know if there is a way to return a CHAR with more than one character.

Here is a sample function that adjusts the size of a char return using substr:

 create or replace function test_func
  2 return char is
  3 --
  4 v_char char(8) ;
  5 --
  6 begin
  7 --
  8 select to_char(sysdate,'YYYYMMDD')
  9 into v_char
 10 from dual;
 11 --
 12 return v_char;
 13 --
 14 end test_func;
 15 /

Function created.

UT1> show errors;
No errors.
UT1> select test_func from dual;

TEST_FUNC



20020827

UT1> select substr(test_func,1,8) as Mydate from dual;

MYDATE



20020827

HTH -- Mark D Powell -- Received on Tue Aug 27 2002 - 13:47:50 CDT

Original text of this message

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