Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q :
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