A Better Routine to Check Social Security Numbers : CHAR VARCHAR2 Functions « PL SQL Data Types « Oracle PL/SQL Tutorial

Oracle PL/SQL Tutorial
1. Introduction
2. Query Select
3. Set
4. Insert Update Delete
5. Sequences
6. Table
7. Table Joins
8. View
9. Index
10. SQL Data Types
11. Character String Functions
12. Aggregate Functions
13. Date Timestamp Functions
14. Numerical Math Functions
15. Conversion Functions
16. Analytical Functions
17. Miscellaneous Functions
18. Regular Expressions Functions
19. Statistical Functions
20. Linear Regression Functions
21. PL SQL Data Types
22. PL SQL Statements
23. PL SQL Operators
24. PL SQL Programming
25. Cursor
26. Collections
27. Function Procedure Packages
28. Trigger
29. SQL PLUS Session Environment
30. System Tables Data Dictionary
31. System Packages
32. Object Oriented
33. XML
34. Large Objects
35. Transaction
36. User Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL/SQL Tutorial » PL SQL Data Types » CHAR VARCHAR2 Functions 
21. 5. 14. A Better Routine to Check Social Security Numbers
SQL>
SQL>
SQL> create or replace function f_validSSN_yn (i_ssn_tx VARCHAR2return VARCHAR2
  2  is
  3      v_out_tx         VARCHAR2(1);
  4      v_temp_string_tx VARCHAR2(256);
  5
  6  begin
  7      if i_ssn_tx is null then
  8          v_out_tx:='N';
  9      elsif length(i_ssn_tx)!=11 then
 10          v_out_tx:='N';
 11      else
 12          v_temp_string_tx:=
 13            translate(i_ssn_tx,'?-0123456789','?');
 14          if v_temp_string_tx is not null
 15          then
 16              v_out_tx:='N';
 17          else
 18              if length(replace(i_ssn_tx,'-'))=then
 19                  v_out_tx:='Y';
 20              else
 21                  v_out_tx:='N';
 22              end if;
 23          end if;
 24      end if;
 25
 26      return v_out_tx;
 27  end;
 28  /

Function created.

SQL>
SQL> select f_validSSN_yn('12345678') from dual;

F_VALIDSSN_YN('12345678')
--------------------------
N

Quote from:

Oracle PL/SQL For Dummies (Paperback)

by Michael Rosenblum (Author), Paul Dorsey (Author)

# Paperback: 414 pages

# Publisher: For Dummies (June 13, 2006)

# Language: English

# ISBN-10: 0764599577

# ISBN-13: 978-0764599576

21. 5. CHAR VARCHAR2 Functions
21. 5. 1. Useful character built-in functions
21. 5. 2. Compare char type value with blank space
21. 5. 3. Compare char type value with 'trim'
21. 5. 4. The most useful character specifications are
21. 5. 5. ASCII
21. 5. 6. SUBSTR
21. 5. 7. INSTR
21. 5. 8. Use the SUBSTR and INSTR at the same time.
21. 5. 9. REPLACE
21. 5. 10. TRANSLATE
21. 5. 11. PAD, RPAD, LPAD
21. 5. 12. TRIM
21. 5. 13. Extending your options with regular expressions
21. 5. 14. A Better Routine to Check Social Security Numbers
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.