Reputation: 464
Hello I'm working with Java connecting to an IBM AS400.
I want to read the timestamp of the last change of a DDS file, e.g. the timestamp of the last SQL operation (INSERT INTO MyLib/MyDDS VALUES (...)
).
In the 5250 terminal, I can go to "work with objects" and open the metadata with choosing option 5 (=show) or simply DSPFD FILE(MyLib/MyDDS)
.
There is the timestamp.
Another way is to run dspjrn jrn(MyLib/MyJournal)
to inspect the journal and its timestamps.
How can I access the timestamps from Java, e.g. using JTOpen or SQL?
Thank you :)
Upvotes: 1
Views: 2006
Reputation: 1
Using QSYS2/SYSTSTAT or QSYS2/SYSTABLESTAT will be slower in response as it is using join files. To achieve this with good performance use
SELECT DBXATS
FROM QSYS/QADBXREF
WHERE (DBXLIB = 'MyLib' and DBXFIL = 'MyDDS')
Upvotes: 0
Reputation: 2163
Java Specific
JT400 (and JTOpen) provides classes and methods that interface with system APIs such as QUSRMBRD and return values usable by Java functions.
For member data changes (and other attributes), see com.ibm.as400.access.MemberDescription field CHANGE_DATE_AND_TIME.
General
Native physical files (PFs) can allow multiple data members that can be separately updated. Members are essentially separate objects (of object type *MBR) from the files (of type *FILE) that contain them. The IFS presents database files as 'containers', i.e., as if they are directories. The members are presented much like streamfiles in a directory, and changes to the content of individual members is tracked by member since the containing file objects only have single 'change' dates.
RTVMBRD is a native command and should always exist. I wouldn't expect it, but authority might restrict access. This would be how CL would normally retrieve data change dates. Alternatively, the Retrieve Member Description (QUSRMBRD) API can be used by any language to retrieve member details.
Upvotes: 1
Reputation: 4014
You can use the ObjectDescription object to get the last change date.
AS400 as400 = new AS400();
ObjectDescription od = new ObjectDescription(as400, "YOURLIB", "FILENAME", "FILE");
Date lastChangeDate = (Date)od.getValue(ObjectDescription.CHANGE_DATE);
Edit: use MemberDescription and MemberDescription.CHANGE_DATE_AND_TIME
Upvotes: 1
Reputation: 734
Use this on your query...
SELECT LAST_USED_TIMESTAMP
FROM QSYS2/SYSTSTAT
WHERE (TABLE_SCHEMA, TABLE_NAME) = ('MyLib', 'MyDDS')
Upvotes: 0
Reputation: 41208
SYSTABLESTAT seems to have the information you are looking for.
SELECT LAST_USED_TIMESTAMP
FROM QSYS2/SYSTABLESTAT
WHERE TABLE_SCHEMA = 'MyLib' AND TABLE_NAME = 'MyDDS'
Upvotes: 3