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 -> in PL/SQL : String replace on some condiations - i hate IF ELSE

in PL/SQL : String replace on some condiations - i hate IF ELSE

From: baka <mesundara_at_hotmail.com>
Date: 14 Jun 2005 00:57:01 -0700
Message-ID: <1118735821.222784.117370@o13g2000cwo.googlegroups.com>


Hello Oracle Gurus's

-Required simple and efficient solution

I want to replace part of the string on some conditions. here is the small pl/SQL code. Oracle 8,9,10G any one is OK but, i will try to avoid owa_text package. (Please pardon me for Not testing under PL/SQL )

Algorithm goes like

1.Here i will read a record from the Database

2.one rows of data is assigned to td_rec;   declare outputstr varchar2(100);

3. Here i am replacing a string

    any one possibilities of replace will be true

  begin
    outputstr:=td_rec.colstr

    outputstr=REPLACE(td_rec.colstr,'TOKYO','JAPAN');
    outputstr=REPLACE(td_rec.colstr,'DELHI','INDIA');
    outputstr=REPLACE(td_rec.colstr,'KPOOR','MALAYSIA');
    outputstr=REPLACE(td_rec.colstr,'PEEKING','CHINA');
    outputstr=REPLACE(td_rec.colstr,'ISMALABADH','PALISTAN');

    etc.............

    outputstr=REPLACE(td_rec.colstr,'NEWYORK','USA');   end;
if there is no match then keep the original string as it is

4.One way of the solution will be
 just keep the beg----end block of step 3 as it is .

If i take this approach all the lines in the beg----end block of step 3 will be checked and its waste of Resources. and i do not want use IF ELSE clause.

Any one have better solution to this problem,

Thanks in Advance Received on Tue Jun 14 2005 - 02:57:01 CDT

Original text of this message

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