• 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
    Maxava

    Migrate IBM i with Confidence

    Tired of costly and risky migrations? Maxava Migrate Live minimizes disruption with seamless transitions. Upgrading to Power10 or cloud hosted system, Maxava has you covered!

    Learn More

    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

  • Public Preview For Watson Code Assistant for i Available Soon
  • COMMON Youth Movement Continues at POWERUp 2025
  • IBM Preserves Memory Investments Across Power10 And Power11
  • Eradani Uses AI For New EDI And API Service
  • Picking Apart IBM’s $150 Billion In US Manufacturing And R&D
  • FAX/400 And CICS For i Are Dead. What Will IBM Kill Next?
  • Fresche Overhauls X-Analysis With Web UI, AI Smarts
  • Is It Time To Add The Rust Programming Language To IBM i?
  • Is IBM Going To Raise Prices On Power10 Expert Care?
  • IBM i PTF Guide, Volume 27, Number 20

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