Well, that was about as useless as IBM's Information Center! It was one of those good ideas that got poorly implemented. The Values keyword does nothing to protect the field at the physical file level. In fact, it doesn't alter the physical file one iota. It comes into play only if the field is referenced in a display file (i.e., you reference the field in the DDS for a display file by specifying an R in position 29 and the REF or REFFLD keyword). The values you specified on the Values keyword then become the only valid values the user can enter for the field in the display file -- not the physical file. OK, so it's a bit more useful than the Information Center. IBM answers the call
'); // -->
olution. This type of physical file constraint allows you to put restrictions on which values are valid for a specific field. For example, you could restrict an inventory type field to allow only 'P' and 'N' (perishable and non-perishable). You can also restrict values to within a given range. You can even restrict the value of a field based on the value of some other field in the same record. You'll need SQL knowledge If you know some basic SQL, you can think of an SQL check-condition as a simple where clause (e.g., it cannot have complicated elements such as subqueries). If you don't know SQL, consider it a fine time to get on board. SQL is the defacto standard in the entire industry. Not knowing SQL in this day and age is akin to a police officer not knowing how to handle a gun. Besides, for check constraints, we are talking only basic knowledge that you can get in probably an hour or less from any SQL book sold by the dozens in major bookstores. No bookstore nearby? Check out the bookstores on the Web. So you can see just how easy it is, here are a couple of examples of SQL check-conditions: The first two examples are equivalent, that is, field INVTYP can be assigned only values 'P' or 'N'. The third example shows you that you can restrict multiple fields with a single constraint. The last example shows how you can restrict the value of a field based on the value of another field (total sales must be less than or equal to the credit limit). Restricting the value of a field based on the value of another field is allowed only when the fields are in the same file; you have to use a trigger if the fields are in different files. How to add a check constraint to a file Alternative: Referential constraints Add two records to it, one with the TYPE field set to 'P' (perishable) and the other with the TYPE field set to 'N' (non-perishable). Then, with the following command, establish a referential constraint to ensure that the INVTYP field in the INVMAST file can be set only to 'P' or 'N': The one advantage to this alternative is you can easily add (or delete) valid values by simply updating the parent file (the INVTYPES file in the above example). Alternative: Triggers -----------------------------------
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| iSeries Security - Security Tools, Physical Security and System Security |
| About Us | Contact Us | For Advertisers | For Business Partners | Site Index | RSS |
|
|
|
|||||||