Author |
Message
|
mahesh4eai |
Posted: Thu Sep 11, 2014 10:47 am Post subject: Current timestamp issue in while loop |
|
|
Novice
Joined: 09 Aug 2014 Posts: 21
|
I am using the Current timestamp in while loop like this:
Esql code:
WHILE (i <= Count) DO
DECLARE Cust_id,Strdate,Strfilename CHARACTER;
SET Strdate = CAST(CURRENT_TIMESTAMP AS CHARACTER FORMAT 'YYYYMMDDhhmmss');
IF (CONTAINS(InputRoot.DFDL.OrderAck.Record[i],'*01')) THEN
SET Cust_id = SUBSTRING(InputRoot.DFDL.OrderAck.Record[i] FROM 4 FOR 4);
SET Strfilename = 'MarketName' || Cust_id || Strdate || '.dat';
SET OutputLocalEnvironment.WrittenDestination.File.Name = Strfilename;
END IF;
SET OutputRoot.DFDL.OrderAck.Record[j] = InputRoot.DFDL.OrderAck.Record[i];
IF(CONTAINS(InputRoot.DFDL.OrderAck.Record[i],'*200')) THEN
SET j = 0;
PROPAGATE TO TERMINAL 'out';
END IF;
SET i = i + 1;
SET j = j + 1;
END WHILE;
But when the records propagated to out terminal one by one and every record have the same timestamp.
Example :Strdate for 1st record is 201409254114604.dat and Strdate for second record also same.
I am expecting different current timestamp values when loop is repeating.Can you please help me for how to resolve this issue?
Last edited by mahesh4eai on Thu Sep 11, 2014 10:51 am; edited 1 time in total |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Sep 11, 2014 10:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
This is just how CURRENT_TIMESTAMP works.
Also, you should change your code to use REFERENCEs instead of using [i].
It will perform *much* faster. |
|
Back to top |
|
 |
mahesh4eai |
Posted: Thu Sep 11, 2014 10:56 am Post subject: |
|
|
Novice
Joined: 09 Aug 2014 Posts: 21
|
Thanks
Last edited by mahesh4eai on Fri Sep 12, 2014 2:34 am; edited 2 times in total |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 11, 2014 10:59 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mahesh4eai wrote: |
i am debugging the flow in slowly,but Strdate value are not changed in 2nd and 3 rd records.. |
No, it won't. As my most worthy associate points out, this is how CURRENT_TIMESTAMP works:
Quote: |
All calls to CURRENT_TIMESTAMP within the processing of one node are guaranteed to return the same value. |
_________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 11, 2014 11:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
My most worthy associate is also right about using references not indexes. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 11, 2014 11:41 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
If you are using java you could get the system date....  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 11, 2014 11:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
fjb_saper wrote: |
If you are using java you could get the system date....  |
Or the OP could read what I told him in his previous post and use ESQL.
Empowered by choice. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|