• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Using Timestamps as Unique Keys

    July 17, 2002 Timothy Prickett Morgan

    Hey, Ted:

    We need to generate unique keys for each record written to a file and thought that the timestamp would make a good unique key for a file. Then we ran into a problem. The RPG TIME op code fills in only the first three digits of the microseconds portion of a timestamp field. The last three digits are always zeros.

    Is there another way in RPG to fill the timestamp with a unique time, such as an op code that fills the last three digits as well?

    — Michael

    Since your concern is that you have a unique value, not that you have an accurate timestamp, let me suggest an alternate approach. Compare the timestamp to the timestamp that was retrieved for the previous record. If they are the same, add one microsecond to get a unique key value.

    D key             s               z                     
    D timestamp       s               z                     
    D timestampsave   s               z                     
    
    C                time                    timestamp   
    C                if        timestamp <> timestampsave
    C                eval      key = timestamp           
    C                eval      timestampsave = timestamp 
    C                else                                
    C                adddur    1:*mseconds   key         
    C                endif                               
    

    — Ted

    Sponsored By
    TRAMENCO

    The Training and Mentoring Company (Tramenco) is dedicated to just one thing: Advancing your career by giving you the skills you need to solve real-world business problems.

    Choose from a menu of training options to fit your needs: onsite seminars, public seminars, mentoring, consulting, books, CBTs, and Web-based training.

    For more information about Tramenco’s career enhancing opportunities, call (800)421-8031 or go to www.tramenco.com.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: mgo_rc, Volume 2, Number 53 -- July 17, 2002

    Sponsored by
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Scheduling a Job to Run More than Once a Day Deleting a Badly Named IFS File

    Leave a Reply Cancel reply

MGO Volume: 2 Issue: 53

This Issue Sponsored By

    Table of Contents

    • Readers Insights and Feedback: Dealing with Record Locks
    • SQL and System/36 File Names
    • Using Timestamps as Unique Keys

    Content archive

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

    Recent Posts

    • The Turning Point For Power Systems Is Here, And Now
    • How IBM i Users Can Compete In The Digital Era With Composable Commerce
    • IBM Streamlines Data Migration With New Partition Mirror Tech
    • Profound Logic Adds MCP To IBM i AI Tool
    • IBM i PTF Guide, Volume 27, Number 29
    • Power11 Entry Machines: The Power S1124 And Power L1124
    • BRMS Isn’t The Only Backup Product With A Security Problem
    • Guru: A Faster Way To Sign A JWT
    • Maxis Adds IBM i Support To Database Modernization Tool
    • IBM i PTF Guide, Volume 27, Number 28

    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