Open In App

PLSQL | SOUNDEX Function

Last Updated : 27 Sep, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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 

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads