× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Dale,

I'm assuming you are using RPG's native I/O (F-specs) instead of SQL to write records to this PF.

The problem is: RPG always writes all of the fields in the external definition. Since your date field is one of the fields in the external definition, RPG will define it, and will specify a default value for it (even if you don't explicitly set a value for that field in your calcs.)

The solution? Create a logical file that contains all of the fields _except_ for the date field. Change the RPG program to use this new logical -- now the external definition that RPG reads will come from the LF instead of the PF, and the LF doesn't contain the date field, so RPG won't supply a value. Now the database manager has to figure out what to assign to the field (since RPG doesn't supply a value) and will choose the default, which is the current date.

Example physical file:

A R TEST
A FIELD1 10A
A FIELD2 10A
A FIELD3 L
K K FIELD1


Example logical file:

A R TEST PFILE(THEPF)
A FIELD1
A FIELD2
K K FIELD1


Example RPG code:

FTHELF O E K DISK
/free
Field1 = 'XXXXXXX';
Field2 = 'YYYYYYY';
write TEST;
*inlr = *on;
/end-free


The result will be the current date in FIELD3, because FIELD3 didn't get a value from the RPG program. (Because it's not in the external definition for THELF).

-SK





On 6/25/2012 3:48 PM, dale janus wrote:
I have a file defined with DDS (it's a long slow process moving to DDL).
It has a date field defined as type L. The default value is current date,
I confirmed it as shown in OPS NAV.

What I want DB2 to do is put in today's date whenever I add a record.
What I get is 0001-01-01.

This is the kind of thing I would like to let DB2 handle. Do I need to
make it a timestamp field for that to work? Or change the definition
with OPS NAV to something else?

I guess I can always update with current date in RPG, but I'm trying to
use some of these new shiny tools that are available.


---Dale







As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.