• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • VALUES: A Truly Useless DDS Keyword

    October 26, 2011 Hey, Ted

    We had a recent crisis in our shop. When we dug to the root of the problem, we found that one of our files had an invalid value in one of the fields. I don’t understand why this was the case, because the programmer who wrote the DDS used the VALUES keyword on the field in question. Does the VALUES keyword not prevent invalid data from entering the database?

    –Paul

    No, Paul. One would think it does, but use of the VALUES keyword only applies to the workstation controller. That is, only the green-screen interface is restricted by the VALUES keyword. There’s nothing to stop an SQL interface or a high-level language program from writing another value to the database.

    Here’s an example of a physical file that uses the VALUES keyword.

    A          R MYREC
    A            ONEFIELD       5A
    A            TWOFIELD       2A
    A            REDFIELD       1P 0       VALUES(1 2 3)
    A            BLUEFIELD      5P 2
    A          K ONEFIELD
    

    Obviously the author’s intention is that REDFIELD must have a whole-number value from 1 to 3.

    However, there is another way. Use a check constraint in SQL, as the following CREATE TABLE command illustrates.

    create table tholtp/qad3020pf
       (onefield  char(5),
        twofield  char(2),
        redfield  dec(1)
           check (redfield between 1 and 3),
        bluefield dec(5,2),
        primary key (onefield))
    

    Now the rule is defined in the database, and nothing can write a value other than 1, 2, or 3 into REDFIELD. Any attempt to write another value will raise error CPF502F (Check constraint violation on member MYFILE).

    Here’s yet one more reason to quit using DDS and start using SQL to define database tables.

    –Ted

    RELATED STORIES

    Handling Constraint Violations in RPG

    Simulate a Boolean Data Type in a Database Table

    Implementing Check Constraints in Referential Integrity



                         Post this story to del.icio.us
                   Post this story to Digg
        Post this story to Slashdot

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    Computer Keyes

    Fax Directly from your IBM i

    KeyesFax is a full function automated IBM i fax system. Spooled files are burst by fax number and auto transmitted with overlays.  It combines both a send and receive facsimile processing system with a complete image package.

    The fax software will edit, send, receive, display, print, and track fax documents or images using any standard IBM i without additional expensive hardware, software or subscriptions.

    Computer Keyes has been developing Software Solutions since 1978!

    www.computerkeyes.com

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    New Generation Software:  FREE Business Intelligence Webinar. November 9
    Dan Riehl Presents:  Fall Training Sale – Discounts up to 40%! RPG IV COBOL CL Admin Security
    Connectria Hosting:  What's your IBM System i strategy? Download our FREE report

    IT Jungle Store Top Book Picks

    BACK IN STOCK: Easy Steps to Internet Programming for System i: List Price, $49.95

    The iSeries Express Web Implementer's Guide: List Price, $49.95
    The iSeries Pocket Database Guide: List Price, $59
    The iSeries Pocket SQL Guide: List Price, $59
    The iSeries Pocket WebFacing Primer: List Price, $39
    Migrating to WebSphere Express for iSeries: List Price, $49
    Getting Started with WebSphere Express for iSeries: List Price, $49
    The All-Everything Operating System: List Price, $35
    The Best Joomla! Tutorial Ever!: List Price, $19.95

    On ‘GTFM’ and a Place for Experts Bang For The Buck on Power7 Gen 2 Servers

    Leave a Reply Cancel reply

Volume 11, Number 32 -- October 26, 2011
THIS ISSUE SPONSORED BY:

ProData Computer Services
WorksRight Software
The 400 School

Table of Contents

  • 10 Facts You Should Know about Special Values
  • VALUES: A Truly Useless DDS Keyword
  • Limiting How Much Memory a Storage Pool Can Allocate

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • IBM Unveils Manzan, A New Open Source Event Monitor For IBM i
  • Say Goodbye To Downtime: Update Your Database Without Taking Your Business Offline
  • i-Rays Brings Observability To IBM i Performance Problems
  • Another Non-TR “Technology Refresh” Happens With IBM i TR6
  • IBM i PTF Guide, Volume 27, Number 18
  • Will The Turbulent Economy Downdraft IBM Systems Or Lift It?
  • How IBM Improved The Database With IBM i 7.6
  • Rocket Celebrates 35th Anniversary As Private Equity Owner Ponders Sale
  • 50 Acres And A Humanoid Robot With An AI Avatar
  • IBM i PTF Guide, Volume 27, Number 17

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle