I am using IBM DB2.
So, I am retrieving a column named SSN
from a table. I have to apply the following regex on that column:
([1-57-8][0-9]{2}
|0([1-9][0-9]
|[0-9][1-9])
|6([0-57-9][0-9]
|[0-9][0-57-9]))
([1-9][0-9]|[0-9][1-9])([1-9]\d{3}|\d[1-9]\d{2}|\d{2}[1-9]\d|\d{3}[1-9])
Someone suggested to me that I have to write a function/procedure in the query to validate that the SSN
picked from the db follows this regex else it should not be stored in the result set of the query.
I don't know how to write a function or a procedure in SQL, can you please help me out here?