ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to set Timestamp multiple times in ESQL

Post new topic  Reply to topic Goto page 1, 2  Next
 How to set Timestamp multiple times in ESQL « View previous topic :: View next topic » 
Author Message
johkar
PostPosted: Sun Dec 04, 2016 9:44 am    Post subject: How to set Timestamp multiple times in ESQL Reply with quote

Novice

Joined: 27 Jan 2015
Posts: 16

The documentation for the ESQL keyword CURRENT_TIMESTAMP and CURRENT_TIME functions say that it retains the same value in the node/flow. I have a need within ESQL to set an updated timestamp from within a loop and then read it later in the flow.

Is there a way to set an updatable timestamp, or perhaps just Time in milliseconds, from ESQL?
Back to top
View user's profile Send private message
adubya
PostPosted: Sun Dec 04, 2016 11:32 am    Post subject: Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

Write a Java class to return what you need and call that from ESQL ?
_________________
Independent Middleware Consultant
andy@knownentity.com
Back to top
View user's profile Send private message Send e-mail
timber
PostPosted: Sun Dec 04, 2016 11:57 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
I have a need within ESQL to set an updated timestamp from within a loop and then read it later in the flow.
Can you explain what you want to do with this timestamp? That way, we can form our own conclusions about whether this is a genuine need. The more we know about the problem, the more likely we are to offer good advice.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Sun Dec 04, 2016 12:06 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

adubya wrote:
Write a Java class to return what you need and call that from ESQL ?


Let me expand a little on this answer with an insight into why this is an answer.


The values returned with the CURRENT_TIMESTAMP and CURRENT_TIME are the same for the entire invocation of that COMPUTE NODE.

By this I mean that when a thread enters a COMPUTE NODE (ESQL) the values returned by these functions remains the same no matter how many times the function is called and how long the flow is executing the code in that COMPTUTE NODE.

If you really, really, really need a different time value for some reason then do as suggested, and create some Java to get the actual system time when you need it.

When I first encountered this I was puzzled as to why it was like this. It didn't seem logical but it wasn't a major issue.
A few years later, I used it to my advandage in a really complex envirnment. There was lots of propagation and use of a collector node. I used the output of CURRENT_TIMESTAMP as a collection identifier.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
johkar
PostPosted: Sun Dec 04, 2016 7:40 pm    Post subject: How to set Timestamp multiple times in ESQL Reply with quote

Novice

Joined: 27 Jan 2015
Posts: 16

Thanks adubya and smdavies99. I searched a bit and found the below link which I think outlines what I need to do. I'll need to consult with a teammate who is a Java developer but think we can get it easy enough.

http://www.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ak04960_.htm
Back to top
View user's profile Send private message
adubya
PostPosted: Sun Dec 04, 2016 11:40 pm    Post subject: Re: How to set Timestamp multiple times in ESQL Reply with quote

Partisan

Joined: 25 Aug 2011
Posts: 377
Location: GU12, UK

johkar wrote:
Thanks adubya and smdavies99. I searched a bit and found the below link which I think outlines what I need to do. I'll need to consult with a teammate who is a Java developer but think we can get it easy enough.

http://www.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ak04960_.htm


Yes, that's it. The documentation is good in that area and it's simple to create a Java class which you can associated with an ESQL FUNCTION specifying LANGUAGE JAVA.
_________________
Independent Middleware Consultant
andy@knownentity.com
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Mon Dec 05, 2016 10:31 am    Post subject: Re: How to set Timestamp multiple times in ESQL Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

johkar wrote:
The documentation for the ESQL keyword CURRENT_TIMESTAMP and CURRENT_TIME functions say that it retains the same value in the node/flow.

More specifically, within each invocation of a node, the current timestamp value remains constant, but it does change from node to node, and even for different invocations of the same node.

For example, if one esql node had a loop with PROPAGATE statement that invokes a second esql node, then for each iteration through the loop, the second esql node would have a different value for current timestamp.

That might be preferable to Java.
Back to top
View user's profile Send private message
Darth Vader
PostPosted: Fri Oct 04, 2019 4:13 am    Post subject: How to set Timestamp multiple times in ESQL Reply with quote

Newbie

Joined: 04 Oct 2019
Posts: 1

I made a Java program which returns the Timestamp and included it in a shared library.
Then I wrote the Java routine procedure for the Java program.

When I'm trying to deploy both the Library and the application it's throwing a lot of errors
Back to top
View user's profile Send private message
timber
PostPosted: Fri Oct 04, 2019 6:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
When I'm trying to deploy both the Library and the application it's throwing a lot of errors
Oh no! And we can't help, because we don't know what the errors are!

Back to top
View user's profile Send private message
gbaddeley
PostPosted: Sun Oct 06, 2019 2:39 pm    Post subject: Re: How to set Timestamp multiple times in ESQL Reply with quote

Jedi

Joined: 25 Mar 2003
Posts: 2492
Location: Melbourne, Australia

johkar wrote:
The documentation for the ESQL keyword CURRENT_TIMESTAMP and CURRENT_TIME functions say that it retains the same value in the node/flow. I have a need within ESQL to set an updated timestamp from within a loop and then read it later in the flow.
Is there a way to set an updatable timestamp, or perhaps just Time in milliseconds, from ESQL?

Even if the timestamp is updatable and available at microsecond or nanosecond resolution, are duplicate timestamps going to cause any issues?

Are you using timestamp as a unique transaction identifier?
_________________
Glenn
Back to top
View user's profile Send private message
mpong
PostPosted: Mon Oct 07, 2019 8:10 am    Post subject: Reply with quote

Disciple

Joined: 22 Jan 2010
Posts: 164

I remember this, I had an issue reported by the developer who noticed IIB is writting same timestamp for multiple rows, we then figured out within loop he was updating multiple DB rows with current timestamp function
Back to top
View user's profile Send private message
rekarm01
PostPosted: Mon Oct 07, 2019 9:36 am    Post subject: Re: How to set Timestamp multiple times in ESQL Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

gbaddeley wrote:
johkar wrote:
The documentation for the ESQL keyword CURRENT_TIMESTAMP and CURRENT_TIME functions say that it retains the same value in the node/flow. I have a need within ESQL to set an updated timestamp from within a loop and then read it later in the flow.

Is there a way to set an updatable timestamp, or perhaps just Time in milliseconds, from ESQL?

Please note that this post is nearly three years old, and appears to have been resolved.

Darth Vader wrote:
I made a Java program which returns the Timestamp ... it's throwing a lot of errors

As explained previously, updating the ESQL timestamp may be preferable to using Java.
Back to top
View user's profile Send private message
vrathod2
PostPosted: Wed Sep 29, 2021 10:21 am    Post subject: Reply with quote

Newbie

Joined: 29 Sep 2021
Posts: 2

Nope, just for getting system timestamp suggesting to use Java its not good one.

You can use PASSTHRU to achieve this

Ex:

PASSTHRU 'INSERT INTO ' || cDBSchema || '.TPI_CURRENT_MASTER VALUES(CURRENT_TIMESTAMP,?,)'
TO Database.{cDSN}
VALUES(tFileTime);

Hope This helps...
Back to top
View user's profile Send private message
vrathod2
PostPosted: Wed Sep 29, 2021 10:23 am    Post subject: Reply with quote

Newbie

Joined: 29 Sep 2021
Posts: 2

smdavies99 wrote:
adubya wrote:
Write a Java class to return what you need and call that from ESQL ?


Let me expand a little on this answer with an insight into why this is an answer.


The values returned with the CURRENT_TIMESTAMP and CURRENT_TIME are the same for the entire invocation of that COMPUTE NODE.

By this I mean that when a thread enters a COMPUTE NODE (ESQL) the values returned by these functions remains the same no matter how many times the function is called and how long the flow is executing the code in that COMPTUTE NODE.

If you really, really, really need a different time value for some reason then do as suggested, and create some Java to get the actual system time when you need it.

When I first encountered this I was puzzled as to why it was like this. It didn't seem logical but it wasn't a major issue.
A few years later, I used it to my advandage in a really complex envirnment. There was lots of propagation and use of a collector node. I used the output of CURRENT_TIMESTAMP as a collection identifier.



Why java,? ..You can use PASSTHRU to achieve this

Ex:

PASSTHRU 'INSERT INTO ' || cDBSchema || '.TPI_CURRENT_MASTER VALUES(CURRENT_TIMESTAMP,?,)'
TO Database.{cDSN}
VALUES(tFileTime);
Back to top
View user's profile Send private message
timber
PostPosted: Thu Sep 30, 2021 3:15 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

@vrathod2: Thanks for the opinion, but I don't think your solution will apply to everybody.

Example: the original post (5 years ago) said:
Quote:
I have a need within ESQL to set an updated timestamp from within a loop and then read it later in the flow.
I don't think a PASSTHRU statement would be much use there, but a simple call to a Java static method would do the job very simply.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » How to set Timestamp multiple times in ESQL
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.