0

I have a requirement where I want to validate a column value which will be something like below.

    1. It should be 18 characters in length.
    1. It should not accept any special characters.

Below is the correct value for that column.

INAPDNCHXXXXTW6002

and the query for getting that value is below

SELECT RJ_NETWORK_ENTITY_ID FROM NE.STRUCTURE WHERE RJ_SAPID = P_SAPID;

So, how can I do this in database level

1
  • 1
    Why do you need to do this in PL/SQL instead of, say, in a database constraint? Commented Sep 8, 2017 at 11:03

1 Answer 1

1

One way to check that value match your requirements, is to use regexp:

REGEXP_LIKE(col, '^[a-z0-9]{18}$', 'i') ;

If you want check that RJ_NETWORK_ENTITY_ID column meets those requirements, you can use:

SELECT RJ_NETWORK_ENTITY_ID FROM NE.STRUCTURE 
WHERE 
RJ_SAPID = P_SAPID 
and 
REGEXP_LIKE(RJ_NETWORK_ENTITY_ID, '^[a-z0-9]{18}$', 'i');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.