Open In App

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:

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 
Article Tags :
SQL