Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Question about CHAR return from function
"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
UT1> select substr(test_func,1,8) as Mydate from dual;
MYDATE
HTH -- Mark D Powell -- Received on Tue Aug 27 2002 - 13:47:50 CDT
![]() |
![]() |