Oracle determines whether a string contains another string

Source: Internet
Author: User

SELECT * from a where InStr (A, B) >0;

To implement a B field that is part of a field, discuss the order or the character that you want to be adjacent.

If you want characters that are either sequential or not contiguous, the definition function can be implemented:

SELECT * from a where InStr (A, B) >0;

This can only be achieved when the B field is a part of the A field. If you want a character that is either sequential or not contiguous, the defined function can implement

Create or Replace functionChecks (v_avarchar2, V_bvarchar)  return  Number   asNum Number; Cou Number; beginNum:= -1; Cou:=0;  forIinch 1.. Length (V_b) loopifInStr (V_a,substr (V_b,i,1))>0  Thencou:=Cou+1; End if; EndLoop; ifCou=Length (V_b) Then     returncou; End if; Dbms_output.put_line (Cou||'    '||Length (v_b)); returnnum; End; results: SQL> Select *  fromA; A B---------- ----------asdf SD asdf ad asdf df asdf asdf SQL> Select *  fromAwhereChecks (A, B)>0; A B---------- ----------asdf SD asdf ad asdf df asdf asdf

Oracle determines whether a string contains another string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.