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

Home -> Community -> Usenet -> c.d.o.server -> Re: Q :

Re: Q :

From: Terrence Wong <mingjun_at_singnet.com.sg>
Date: 1997/07/29
Message-ID: <33DD58F0.94EDD222@singnet.com.sg>#1/1

Srini Narayanan wrote:
>
> Hi,
>
> I want to write a function repeat which i would be using in select
> statments.
>
> My question is this : How do i give an exception
>
> create or replace function repeat(str varchar, n number ) return
> varchar as
> ostr varchar(2000) := NULL;
> i number(3) := 1;
> str_err exception ;
> begin
> while i <= n loop
> ostr := ostr||str ;
> if( length(ostr) >= 10 ) then
> raise str_err ;
> end if;
> i := i + 1 ;
> end loop ;
> return ostr ;
> exception
> dbms_output.put_line('The field is greater tha MAX') ;
>
> end ;

Try inserting the "WHEN str_err THEN" statement.

> exception

 WHEN str_err THEN
> dbms_output.put_line('The field is greater tha MAX') ;

Hope this solves your problem.
Terrence Wong
Systems Developer Received on Tue Jul 29 1997 - 00:00:00 CDT

Original text of this message

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