We noticed in a couple of programs where we were using timestamps that the rightmost three positions are consistently zero and never otherwise. I have tested this with even just a simple ILE RPG program that dsplys a %char(%timestamp()); and still only get zeros for the last three digits.
However...pulling a microsecond(current timestamp) in an interactive SQL session provides a value which has all six digits being used.
So, is this a limitation of RPG? Is there something else I am missing? Is anyone else using microseconds at all in RPG that can vouch for this ever using the last three digits?
Thanks in advance!!
Software/Hardware used:
ASKED:
May 15, 2009 2:43 PM
UPDATED:
January 9, 2011 4:56 PM
Wilson, thanks for the verification of what we suspected.
Yes, it would be nice to get the whole 6 because the timestamp is being used in an audit trail. We want to be able to look at the audit trail and sort it by the timestamp to see the exact sequence of events recorded. But, with the speed of the events that take place, nearly all of them happen within the exact same time according to the timestamp. I figured that the remaining three digits may make enough difference to help.
I had not considered an API, but I’ll see if I can dig up one that gets me the data. I’ll post whatever I find here for the benefit of others.
I couldn’t find an API, and no one installed the C compiler, so I just ended up just using embedded SQL to do:
/exec sql
select microsecond(current timestamp) into :tmpfield from sysibm/sysdummy1;
I also created a small SQLRPGLE program that could be called by other programs to return this value. Hope this helps someone else who stumbles onto this limitation!
Great, BigKat! Thanks!! I knew there must’ve been a simpler way in SQL… ^_^
Wilson,
Can I use Qp0zCvtToMITime in RPG w/o using C at all? If so, that would be cool. But, the only examples I saw just now for that API were in C.
Thanks!
Hi,
Yes you can call this APIs from RPGILE and you just need to know haw to pass parameters to this APIs. Just take a look to this page :
Regards,
Wilson