• 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
    WorksRight Software

    Do you need area code information?
    Do you need ZIP Code information?
    Do you need ZIP+4 information?
    Do you need city name information?
    Do you need county information?
    Do you need a nearest dealer locator system?

    We can HELP! We have affordable AS/400 software and data to do all of the above. Whether you need a simple city name retrieval system or a sophisticated CASS postal coding system, we have it for you!

    The ZIP/CITY system is based on 5-digit ZIP Codes. You can retrieve city names, state names, county names, area codes, time zones, latitude, longitude, and more just by knowing the ZIP Code. We supply information on all the latest area code changes. A nearest dealer locator function is also included. ZIP/CITY includes software, data, monthly updates, and unlimited support. The cost is $495 per year.

    PER/ZIP4 is a sophisticated CASS certified postal coding system for assigning ZIP Codes, ZIP+4, carrier route, and delivery point codes. PER/ZIP4 also provides county names and FIPS codes. PER/ZIP4 can be used interactively, in batch, and with callable programs. PER/ZIP4 includes software, data, monthly updates, and unlimited support. The cost is $3,900 for the first year, and $1,950 for renewal.

    Just call us and we’ll arrange for 30 days FREE use of either ZIP/CITY or PER/ZIP4.

    WorksRight Software, Inc.
    Phone: 601-856-8337
    Fax: 601-856-9432
    Email: software@worksright.com
    Website: www.worksright.com

    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

    • POWERUp 2025 –Your Source For IBM i 7.6 Information
    • Maxava Consulting Services Does More Than HA/DR Project Management – A Lot More
    • Guru: Creating An SQL Stored Procedure That Returns A Result Set
    • As I See It: At Any Cost
    • IBM i PTF Guide, Volume 27, Number 19
    • 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

    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