I'm a beginner on oracle apex and im trying to implement a constraint that only allows variables in a column that start with a certain letter ('P') and are followed by numeric digits. Any help?
Asked
Active
Viewed 900 times
1 Answers
1
You could use the regexp_like
operator:
ALTER TABLE mytable
ADD CONSTRAINT mytable_field_check
CHECK (REGEXP_LIKE (myfiled, 'P[0-9]*'))

Mureinik
- 297,002
- 52
- 306
- 350
-
I tried before but it prompts me for an invalid relational operator – Stavros Kasapi Mar 22 '17 at 07:48
-
@StavrosKasapi please share your exact statement and error message – Mureinik Mar 22 '17 at 07:49
-
found it!!ALTER TABLE Product_SK ADD CONSTRAINT Product_SK_ProductCode_check CHECK (REGEXP_LIKE (ProductCode,'P[0-9]*')) – Stavros Kasapi Mar 22 '17 at 07:53
-
@StavrosKasapi Arg, I got caught up in `like`'s syntax. Edited and fixed. Thanks! – Mureinik Mar 22 '17 at 07:55