Enforce only alphabets in a particular field of physical file

20 pts.
Tags:
AS/400 development
Data Types
what is the keyword to enforce entry of only alphabets in a particular field of physical file??? for ex: NAME field of EMPLOYEE MASTER.

Answer Wiki

Thanks. We'll let you know when a new response is added.

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)
CHKCST(‘translate(NAME,
”………………………”,
”ABCDEFGHIJKLMNOPQRSTUVWXYZ ”)=”……….”’)</pre>
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.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following