Re: basic plsql question

From: Alex Filonov <afilonov_at_yahoo.com>
Date: 31 Aug 2004 12:52:37 -0700
Message-ID: <336da121.0408311152.29e06017_at_posting.google.com>


r0cky_at_insightbb.com (Wario) wrote in message news:<9204a53e.0408301136.51b33314_at_posting.google.com>...
> This procedure is better. You could use the translate function alone,
> but the string parameters would make your code long and unwieldy.
>
> create function word_fmt (word varchar2) return varchar2 is
> begin
> return translate(word,
> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
> 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9999999999'
> );
> end;
>

First character should be 'a' or 'A', other four characters are digits, so translate function call can look like

translate(word, 'aA0123456789', 'AA9999999999')

> if word_fmt('a52132') = 'X99999' then
> .....
> end if;
>
> or
>
> if translate(word, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
> 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX9999999999') =
> 'X99999' then
> ....
> end if;
Received on Tue Aug 31 2004 - 21:52:37 CEST

Original text of this message