Cause :- Invalid character set using in regular expression.
SQL> CREATE TABLE REGEXP_LIKE_TEST (ID NUMBER, NAME VARCHAR2(20), SALARY NUMBER);
Table created.
SQL>
SQL> ALTER TABLE REGEXP_LIKE_TEST
2 ADD CONSTRAINT REGEXP_LIKE_TEST_CONST CHECK (REGEXP_LIKE(NAME,'[[:ALPHA:]]')) NOVALIDATE ;
Table altered.
SQL>
SQL> INSERT INTO REGEXP_LIKE_TEST VALUES(10, 'RAJIB',5000);
INSERT INTO REGEXP_LIKE_TEST VALUES(10, 'RAJIB',5000)
*
ERROR at line 1:
ORA-12729: invalid character class in regular expression
Solution :- Using valid character set within regular expression.
SQL> ALTER TABLE REGEXP_LIKE_TEST
2 DROP CONSTRAINT REGEXP_LIKE_TEST_CONST;
Table altered.
SQL> ALTER TABLE REGEXP_LIKE_TEST
2 ADD CONSTRAINT REGEXP_LIKE_TEST_CONST CHECK (REGEXP_LIKE(NAME,'[[:alpha:]]')) NOVALIDATE ;
Table altered.
SQL> INSERT INTO REGEXP_LIKE_TEST VALUES(10, 'RAJIB',5000);
1 row created.
SQL>
SQL> CREATE TABLE REGEXP_LIKE_TEST (ID NUMBER, NAME VARCHAR2(20), SALARY NUMBER);
Table created.
SQL>
SQL> ALTER TABLE REGEXP_LIKE_TEST
2 ADD CONSTRAINT REGEXP_LIKE_TEST_CONST CHECK (REGEXP_LIKE(NAME,'[[:ALPHA:]]')) NOVALIDATE ;
Table altered.
SQL>
SQL> INSERT INTO REGEXP_LIKE_TEST VALUES(10, 'RAJIB',5000);
INSERT INTO REGEXP_LIKE_TEST VALUES(10, 'RAJIB',5000)
*
ERROR at line 1:
ORA-12729: invalid character class in regular expression
Solution :- Using valid character set within regular expression.
SQL> ALTER TABLE REGEXP_LIKE_TEST
2 DROP CONSTRAINT REGEXP_LIKE_TEST_CONST;
Table altered.
SQL> ALTER TABLE REGEXP_LIKE_TEST
2 ADD CONSTRAINT REGEXP_LIKE_TEST_CONST CHECK (REGEXP_LIKE(NAME,'[[:alpha:]]')) NOVALIDATE ;
Table altered.
SQL> INSERT INTO REGEXP_LIKE_TEST VALUES(10, 'RAJIB',5000);
1 row created.
SQL>
Helpful! Thank you.
ReplyDelete