Tuesday 22 May 2012

Find String In PeopleCode Using SQL



With Srch As
(
Select Str, SubStr(Max(HexStr),3) Srch_Str
From
(
Select RNum, Str, Hexcode, Sys_connect_by_path(HexCode, '00') HexStr
From (
Select RNum, Str, Chr(Floor(Mod(Code/16, 16))
           + Decode(Floor(Floor(Mod(Code/16, 16))/10), 0, 48, 55)) ||
       Chr(Mod(Code, 16)
           + Decode(Floor(Mod(Code, 16)/10), 0, 48, 55)) HexCode
From (        
Select RNum, Str, Ascii(Substr(Str, RNum, 1)) Code
  From (Select Rownum RNum From Dual Connect By Level <= Length(:Str)),
       (Select :Str Str From Dual
        Union
        Select Upper(:Str) From Dual
        Union
        Select Lower(:Str) From Dual
        Union
        Select InitCap(:Str) From Dual
       )
 ))
Start With RNum = 1 Connect By Prior RNum = RNum - 1 And Prior Str = Str
)
Group By Str
)
Select
Str, P.*
From PSPCMPROG P, Srch
Where DBMS_LOB.INSTR(PROGTXT, Srch_Str)  > 0;

No comments:

Post a Comment