PLSQL | SOUNDEX Function

The PLSQL SOUNDEX function is used for returning a phonetic representation of a string. The phonetic represents the way the string will sound. The PLSQL SOUNDEX function helps to compare words that are spelled differently, but sound alike in English.

The SOUNDEX function accepts one parameter input_string which can be of any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The return value is the same datatype as char.

Syntax:



SOUNDEX( input_string )

Parameters Used:

input_string – It is used to specify the string whose phonetic representation you want to know.

Note:

  • The value returned by the SOUNDEX function will always begin with the first letter of the input_string.
  • The SOUNDEX function uses only the first 5 consonants to determine the NUMERIC portion of the return value, except if the first letter of string1 is a vowel.
  • The SOUNDEX function is not a case-sensitive function.

Supported Versions of Oracle/PLSQL:

  1. Oracle 12c
  2. Oracle 11g
  3. Oracle 10g
  4. Oracle 9i
  5. Oracle 8i

Example-1:

DECLARE 
   Test_String string(25) := 'geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(SOUNDEX(Test_String)); 
   
END;     

Output:

G216 



Example-2:

DECLARE 
   Test_String string(25) := 'GEEKSFORGEEKS';
   
BEGIN 
   dbms_output.put_line(SOUNDEX(Test_String)); 
   
END;  

Output:

G216 



Example-3:

DECLARE 
   Test_String string(25) := 'Hello';
   
BEGIN 
   dbms_output.put_line(SOUNDEX(Test_String)); 
   
END;  

Output:

H400 



Example-4:

DECLARE 
   Test_String string(25) := 'Hello';
   
BEGIN 
   dbms_output.put_line(SOUNDEX(Test_String)); 
   
END;  

Output:

H400 



Example-5:

DECLARE 
   Test_String string(25) := 'Hello User';
   
BEGIN 
   dbms_output.put_line(SOUNDEX(Test_String)); 
   
END;  

Output:

H426 


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.