This SQL create .. you could also use an alter
Creates a constraint on the first postion of the field to A-Z
For this method you would use a seperate constraint for each position of the field
This won’t allow the position to be blank or lower case or anything but A-Z.
CREATE TABLE COCCLEVIN/TBL1 (FLD1 CHAR ( 5) NOT NULL WITH DEFAULT,
CHECK (substr(Fld1,1,1) between ‘A’ and ‘Z’ ))
But note that there are numerous non-alphabetic characters between ‘A’ and ‘Z’. And a CREATE TABLE might be difficult when the PF already exists.
Two general alternatives would be a trigger program and a different constraint. A trigger program could do any kind of verification on any field. A constraint might be like:<pre>
ADDPFCST FILE(EMPLOYEEMASTER) TYPE(*CHKCST) CST(Alpha_Only)
The constraint translates every alphabetic character or blank to a dot. The result is required to be a string of ten dots. If NAME is 20 characters, then it would need to be 20 dots, or whatever length is needed.
Any non-alpha characters would not be translated, so the result couldn’t be all dots and the equals comparison would fail.
I’m sure there are better alternatives, but it works and might be understandable. The idea of a ‘check constraint’ seems useful in this case.