Reputation: 137
How can I add character length in a field on Informix 4GL. I have a description column, and I want to enforce a minimum length 10 characters in this field; if the entered string is less than 10 characters, send the user back to re-enter the data.
Upvotes: 1
Views: 376
Reputation: 754410
To enforce that constraint, you would need to use an AFTER FIELD clause, check the length of the entered data, and send the user back if it is not long enough:
AFTER FIELD mustbe10
IF LENGTH(recname.mustbe10) < 10 THEN
MESSAGE "You must enter at least 10 characters"
NEXT FIELD mustbe10
END IF
I'm assuming it is a field that does not allow nulls; if it does allow nulls, you need to allow for that in the testing.
Incidentally, you can seriously expect to have to deal with descriptions like 'Aaaaaaaaaa' and 'asdfasdfasdf' if you put this requirement on users. They may also get more creative; you can fit a couple of 4-letter words and an exclamation mark into a 10-character limit.
Upvotes: 1