Re: How to limit the size of the returned value from a Stored Function?

From: N Prabhakar <prabhs_at_po.pacific.net.sg>
Date: 1996/11/13
Message-ID: <56cefc$ifn_at_newton.pacific.net.sg>#1/1


vahidt_at_ibm530.vitek.com (Vahidt A. Tadjkarimi) wrote:
>I was wondering if it is possible to limit the size of a returned
>value from a Stored Function. Here is a small example:
>
>CREATE OR REPLACE FUNCTION plus_minus_f (val_1 IN NUMBER, val_2 IN
>NUMBER) RETURN CHAR
>
>IS
>
>BEGIN
> IF ((val_1 - val_2)/val_2) > 0.20) THEN
> RETURN ('+');
> ELSE
> RETURN ('-')
> END IF;
>END;
>/
>
>Once I call this function from a view or by itself the size of the
>returned value is VARCHAR2(2000) !!! Any hints?
>

Two things can be performed.

  1. Instead of returning CHAR datatype, return VARCHAR2 datatype.
  2. When you return a value, try LTRIM(RTRIM(return_value))
  3. If both of the above option does not work, then return

   SUBSTR(LTRIM(RTRIM(return_value)),1)

Regards

N.Prabhakar
Socgen Crosby Securities
Singapore. Received on Wed Nov 13 1996 - 00:00:00 CET

Original text of this message