Oracle: Get length of partial string match -


Imagine I have a table like

  name ---- ABCDEFG ABChello world I always ask a question from the beginning and find out how many letters of each string want to match the desired string "ABCDEFGHIJ,". This is the reason ...  
  name is MatchingLength ---- ---- ABCDEFG 7 ABChello World 3 ABCDEzoo 5 ABbar 2 ABCDEF 6 ABCDEFGHIJKLMNOP 10 zzz 0 qABCD 0 ABCqqqGH 3 ABCABC 3 < / Code>  

Is there any way to do this properly in Oracle? I'm getting hurt

"clean" is not known, but here are two solutions.

  - Strict, poor performance though your strings have no change as pattern (substr selection ('ABCDEFGHIJ', 1, ROWNUM) with double txt level & lt; = Selection of length ('ABCDEFGHIJ')) d.txt, organized (maximum (length (p.txt)), 0) Dummy D, except pattern p on instr (d.txt, p.txt) = 2 by group d 1 group by .txt command; - A calm with reggae. However, changing your input string - like in previous examples, is more complex than the last, - as Oracle is useless with string change. It is also easy to do something that can be done with making it transorms is. Although you can write it in Java, select d.txt, insert (LENGTH (REGEXP_SUBSTR (d.txt, '^ a (b (c (d (e (f (g (h (i)?)? )?)?)?)?)?)?) ')), 0) Dummy D; With pattern (select substrust ('ABCDEFGHI', 1, with RowLlum)   

UPDATE < Pre> ) from txt double level & lt; = Select d.txt from the length ('ABCDEFGIIJ'), choose Collage (max (length (p.txt)), 0) drop on dummy pattern on instr (d.txt, p.txt) = 1 where d.txt LIKE substr ('ABCDEFGHIJ', 1, 1) || '%' Group by d.txt command 2 characters;

Updated Bella:

Select Oracle 10G

 , Goal = ALL_ROWS Sort Order Sort Group Nocent Nested Loops Outer Index Range Scan I & lt; & Lt; & Lt; Index uses fast dual     view the disk without filters

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -