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

Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL function return value

Re: SQL function return value

From: Mark D Powell <markp7832_at_my-deja.com>
Date: Fri, 26 Jan 2001 16:24:24 GMT
Message-ID: <94s8bb$tuu$1@nnrp1.deja.com>

In article <94s5pl$rib$1_at_nnrp1.deja.com>,   derf23456_at_my-deja.com wrote:
> I use "To_Char ( ??? , 'DD-Mon-YYYY HH24:MI:SS' )" a lot and, being
> lazy, created a function:
>
> Create or Replace function Long_Date ( In_Date Date )
> Return Varchar2
> Is
> Begin
> Return ( To_Char ( In_Date , 'DD-Mon-YYYY HH24:MI:SS' ) ) ;
> End Long_Date ;
> /
>
> I'd expected a 20 character string as the return value but it seems
> that I'm getting a string with a length equal to my SQL*Plus setting
> for LineSize.
>
> "Select Long_Date ( SysDate ) , Dummy From Dual ;" returns:
>
> LONG_DATE(SYSDATE)
> ----------------------------------------------------------------------
 --
> D
> -
> 25-Jan-2001 08:09:15
> X
>
> (Using "SubStr ( To_Char ( In_Date , ...) , 1 , 20 )" in the function
> doesn't change the return value.)
>
> How can I get only the "proper" length from my select?
>

Try formatting the column in sqlplus
column return_date format a20

select long_date(sysdate) as return_date from dual;

--
Mark D. Powell  -- The only advice that counts is the advice that
 you follow so follow your own advice --


Sent via Deja.com
http://www.deja.com/
Received on Fri Jan 26 2001 - 10:24:24 CST

Original text of this message

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