Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Timestamp field without DFT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Timestamp field without DFT

    acszimmy wrote: > > We added a timestamp field to a file and did not specify a DFT value. According to the IBM documentation, it should default to the current date/time when you add a record to the file. It does so from DBU, SQL and CPYF, but when we write a record in an RPG program, it gets a value of 0001-01-01-00.00.00.000000. Is there any way to get this to work from RPG, or do we have to change all of our programs to overtly populate the new field with the system time? When you write a record using O specs, RPG uses RPG default values for the fields you don't specify on O specs. The system default of the current date/time would be in effect if RPG didn't even know about the field; that would be the case if the RPG program was using a logical file that didn't have the timestamp field. So using such a logical file would be the easiest way, assuming your RPG programs don't need those timestamp fields for anything else. You could get your program fields _initialized_ with the database default values by using an externally described DS with INZ(*EXTDFT), but your timestamp fields wouldn't get the current value on every record; they would all get the same initialization timestamp. Fmyfile o e disk D e ds inz(*extdft) extname(myfile)

  • #2
    Timestamp field without DFT

    We added a timestamp field to a file and did not specify a DFT value. According to the IBM documentation, it should default to the current date/time when you add a record to the file. It does so from DBU, SQL and CPYF, but when we write a record in an RPG program, it gets a value of 0001-01-01-00.00.00.000000. Is there any way to get this to work from RPG, or do we have to change all of our programs to overtly populate the new field with the system time? Thanks! Steve Zimmerman, Applied Card Systems, Glen Mills, PA
    Code

    Comment


    • #3
      Timestamp field without DFT

      When writing a record from within an RPG program, it should be considered good practice to initialize ALL of your fields in the record regardless of their type. If there are some Alpha fields that will not take on a value, initialize them to blanks. If there are some fields of numeric without a value, initialize them to zero. If you have date or time fields the same rule should apply, either initialize them to a NULL value, or the current date/time. In free-format to put the current date and time in the field, do the following; TTcurdate = %date(); TTcurtime = %time(); Hopefully I understood your question correctly. Good luck!

      Comment

      Working...
      X