Solved

SSN Format in Oracle

Posted on 2016-09-15
2
73 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Extract the first word (before the , ) 2 37
Very interesting Access query problem. 13 70
Oracle Pivot Question 8 43
Use of Exception to end a Loop 3 0
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.

937 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now