1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| WITH t AS (SELECT 'aZERT12345' AS v FROM dual
UNION ALL SELECT 'XXXX123' AS v FROM dual
UNION ALL SELECT 'XXXXX12345' AS v FROM dual
UNION ALL SELECT 'XX-AA12345' AS v FROM dual
UNION ALL SELECT 'XXXXX12A45' AS v FROM dual
)
SELECT v, LENGTH(v) verif_l10, LENGTH(RTRIM(v, '0123456789')) verif_55,
TRANSLATE(UPPER(RTRIM(v, '0123456789')), '0ABCDEFGHJIJKLMNOPQRSTUVWXYZ','0') verif_carac,
CASE WHEN LENGTH(v) = 10 AND LENGTH(RTRIM(v, '0123456789')) = 5
AND TRANSLATE(UPPER(RTRIM(v, '0123456789')), '0ABCDEFGHJIJKLMNOPQRSTUVWXYZ','0') IS NULL THEN 'OK'
ELSE 'KO' END
AS ok_5car_5num
FROM t
V VERIF_L10 VERIF_55 VERIF_CARAC OK_5CAR_5NUM
aZERT12345 10 5 OK
XXXX123 7 4 KO
XXXXX12345 10 5 OK
XX-AA12345 10 5 - KO
XXXXX12A45 10 8 12 KO |
Partager