Validate a zip code : Like « PL SQL Operators « Oracle PL/SQL Tutorial






SQL> SET ECHO ON
SQL>
SQL> CREATE OR REPLACE FUNCTION area_code (phone_number IN VARCHAR2)
  2  RETURN VARCHAR2 AS
  3  BEGIN
  4    IF phone_number LIKE '___-___-____' THEN
  5      RETURN SUBSTR(phone_number,1,3);
  6    ELSE
  7      RETURN 'none';
  8    END IF;
  9  END;
 10  /

Function created.

SQL>
SQL>








23.6.Like
23.6.1.LIKE
23.6.2.Use like in PL/SQL
23.6.3.Validate a zip code
23.6.4.Use the LIKE operator