Author |
Message
|
johkar |
Posted: Sun Dec 04, 2016 9:44 am Post subject: How to set Timestamp multiple times in ESQL |
|
|
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 |
|
 |
adubya |
Posted: Sun Dec 04, 2016 11:32 am Post subject: |
|
|
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 |
|
 |
timber |
Posted: Sun Dec 04, 2016 11:57 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
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 |
|
 |
smdavies99 |
Posted: Sun Dec 04, 2016 12:06 pm Post subject: |
|
|
 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 |
|
 |
johkar |
Posted: Sun Dec 04, 2016 7:40 pm Post subject: How to set Timestamp multiple times in ESQL |
|
|
Novice
Joined: 27 Jan 2015 Posts: 16
|
|
Back to top |
|
 |
adubya |
Posted: Sun Dec 04, 2016 11:40 pm Post subject: Re: How to set Timestamp multiple times in ESQL |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
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 |
|
 |
rekarm01 |
Posted: Mon Dec 05, 2016 10:31 am Post subject: Re: How to set Timestamp multiple times in ESQL |
|
|
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 |
|
 |
Darth Vader |
Posted: Fri Oct 04, 2019 4:13 am Post subject: How to set Timestamp multiple times in ESQL |
|
|
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 |
|
 |
timber |
Posted: Fri Oct 04, 2019 6:15 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
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 |
|
 |
gbaddeley |
Posted: Sun Oct 06, 2019 2:39 pm Post subject: Re: How to set Timestamp multiple times in ESQL |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 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 |
|
 |
mpong |
Posted: Mon Oct 07, 2019 8:10 am Post subject: |
|
|
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 |
|
 |
rekarm01 |
Posted: Mon Oct 07, 2019 9:36 am Post subject: Re: How to set Timestamp multiple times in ESQL |
|
|
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 |
|
 |
vrathod2 |
Posted: Wed Sep 29, 2021 10:21 am Post subject: |
|
|
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 |
|
 |
vrathod2 |
Posted: Wed Sep 29, 2021 10:23 am Post subject: |
|
|
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 |
|
 |
timber |
Posted: Thu Sep 30, 2021 3:15 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
@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 |
|
 |
|