• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 301
  • Last Modified:

SSN Format in Oracle

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
metalteck
Asked:
metalteck
  • 2
1 Solution
 
johnsoneSenior Oracle DBACommented:
What is the TO_CHAR for?  It is already a character field.  You just need to remove the -

replace(emp.fica_nbr,'-') SSNBR
0
 
johnsoneSenior Oracle DBACommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now