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: Here is how to transform "DADD2PBA" to "DA2PPB"

Re: Here is how to transform "DADD2PBA" to "DA2PPB"

From: Christopher Beck <clbeck_at_us.oracle.com>
Date: Wed, 28 Oct 1998 16:44:20 GMT
Message-ID: <363745d3.59279709@dcsun4.us.oracle.com>


On Wed, 28 Oct 1998 12:55:22 GMT, p0070621_at_brookes.ac.uk (Tommy Wareing) wrote:

>
>
>This is the thing that makes me cringe most about PL/SQL: the need to
>declare temporary strings with a maximum size: in this case 2000
>characters. I know this seems large enough for all practical purposes
>(and probably is), but Oracle 8 allows the limit to go up to 4000
>characters, which could result in this code producing a VALUE_ERROR
>exception, which is always embarrasing.

In PL/SQL you can declare varchars of length up to 32K in both Oracle7 and Oracle8.

declare
  v varchar2(32767);
begin
  v := 'I an hold 32K';
end;

chris.

>
>Here's a version which doesn't require that maximum limit:
>create or replace
>
>FUNCTION remdups(a in varchar2)
>RETURN varchar2 IS
>BEGIN
> IF a IS NULL THEN RETURN NULL;
> ELSE RETURN SUBSTR(a, 1, 1)||
> remdups(REPLACE(SUBSTR(a, 2), SUBSTR(a, 1, 1)));
> END IF;
>END;
>
>The first character of a string is returned. We remove this character
>from the remainder of the string, and repeat the duplication removal
>on that remainder. Doncha just lurv recursion. :-)
Received on Wed Oct 28 1998 - 10:44:20 CST

Original text of this message

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