Solved

SSN Format in Oracle

Posted on 2016-09-15
2
110 Views
Last Modified: 2016-09-21
I'm using the following code to format the ssn#s :
to_char(replace(emp.fica_nbr,'-'),999999999) SSNBR

The only issue is if a ssn# starts with 0, it is being omitted.
How can I adjust the code to capture all numbers, even if the leading one is a 0?
0
Comment
Question by:metalteck
  • 2
2 Comments
 
LVL 34

Expert Comment

by:johnsone
ID: 41800541
What is the TO_CHAR for?  It is already a character field.  You just need to remove the -

replace(emp.fica_nbr,'-') SSNBR
0
 
LVL 34

Accepted Solution

by:
johnsone earned 500 total points
ID: 41800545
If you insist on the TO_CHAR, then this would do it, but you are doing a lot of unnecessary conversion.

to_char(to_number(replace(emp.fica_nbr,'-')),'000000000')
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Oracle Distributed Transaction Lock Error ORA-01591 8 52
oracle collections 2 20
sql server query 12 25
SQL Syntax Grouping Sum question 7 24
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question