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 » current time

Post new topic  Reply to topic
 current time « View previous topic :: View next topic » 
Author Message
madi
PostPosted: Thu Mar 30, 2006 8:01 am    Post subject: current time Reply with quote

Chevalier

Joined: 17 Jan 2006
Posts: 475

Hi All

I am trying to create an ID out of the current date and time. this is the porcedure I use for that:

Code:
CREATE PROCEDURE CreateBatchRefId(
OUT batchRefId CHARACTER)
BEGIN
   
   --      Code to create the batchRefId
   DECLARE tyear CHAR CAST(EXTRACT(YEAR FROM CURRENT_DATE) AS CHAR);
   DECLARE tmonth CHAR CAST(EXTRACT(MONTH FROM CURRENT_DATE) AS CHAR);
   WHILE LENGTH(tmonth) < 2 DO
      SET tmonth = '0' || tmonth;
   END WHILE;
   DECLARE tday CHAR CAST(EXTRACT(DAY FROM CURRENT_DATE) AS CHAR);
   WHILE LENGTH(tday) < 2 DO
      SET tday = '0' || tday;
   END WHILE;
   DECLARE thour CHAR CAST(EXTRACT(HOUR FROM CURRENT_TIME) AS CHAR);
   WHILE LENGTH(thour) < 2 DO
      SET thour = '0' || thour;
   END WHILE;
   DECLARE tmin CHAR CAST(EXTRACT(MINUTE FROM CURRENT_TIME) AS CHAR);
   WHILE LENGTH(tmin) < 2 DO
      SET tmin = '0' || tmin;
   END WHILE;
   DECLARE tsec INT CAST(EXTRACT(SECOND FROM CURRENT_TIME) AS INT);
   DECLARE tcsec CHAR CAST(tsec AS CHAR);
   WHILE LENGTH(tcsec) < 2 DO
      SET tcsec = '0' || tcsec;
   END WHILE;
   DECLARE tmsec CHAR SUBSTRING(CAST(CURRENT_TIMESTAMP AS CHAR) FROM (LENGTH(CAST(CURRENT_TIMESTAMP AS CHAR)) - 6) FOR 3);
   
   SET batchRefId = 'MB' || tyear || tmonth || tday|| thour|| tmin|| tcsec || tmsec;
   
END;


So I am calling this function many times within a compute module and I get the same batchRefId everytime when I expect to get different Id becoz the time is gonna be different.

So my conclusion on this would be the compute node is getting the current time and beginning of the process and not everytime we are calling them.

how can i get the real current time?

--madi
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Mar 30, 2006 8:21 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Well, there are still UUIDASCHAR and UUIDASBLOB, so you can use those instead of a timestamp as a unique identifier.

Also, I think you can get better time resolution from Java.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
wschutz
PostPosted: Thu Mar 30, 2006 9:05 am    Post subject: Reply with quote

Jedi Knight

Joined: 02 Jun 2005
Posts: 3316
Location: IBM (retired)

Quote:
CURRENT_TIME returns a TIME value representing the current local time. As with all SQL functions that take no parameters, no parentheses are required or accepted. All calls to CURRENT_TIME within the processing of one node are guaranteed to return the same value.


_________________
-wayne
Back to top
View user's profile Send private message Send e-mail AIM Address
jefflowrey
PostPosted: Thu Mar 30, 2006 9:15 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

It is possible to get more granularity from Java.

Here's an evaluate function for a JavaCompute node that adds two different timestamps to the local environment.

public void evaluate(MbMessageAssembly assembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");


// ----------------------------------------------------------
// Add user code below


MbMessage env = assembly.getLocalEnvironment();
MbMessage newEnv = new MbMessage(env);
MbElement oleRoot = newEnv.getRootElement();
SimpleDateFormat formatter;

formatter = new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss.SSS z", Locale
.getDefault());
Date today = new Date();
oleRoot.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"currentTime1", formatter.format(today));
today = new Date();
oleRoot.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"currentTime2",formatter.format(today));



MbMessageAssembly outAssembly = new MbMessageAssembly(
assembly,
newEnv,
assembly.getExceptionList(),
assembly.getMessage());


// End of user code
// ----------------------------------------------------------

// The following should only be changed
// if not propagating message to the 'out' terminal

out.propagate(outAssembly);
}
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
jbanoop
PostPosted: Sat Apr 01, 2006 12:39 am    Post subject: Reply with quote

Chevalier

Joined: 17 Sep 2005
Posts: 401
Location: SC

Hi,
If you want to get the exact timestamps at different points in an ESQL compute module, you could have a java method called from ESQL (refer calling external java method from ESQL) when ever you need the current timestamp.
We have done it that way to get exact time stamp from ESQL.

Regards,
Anoop
Back to top
View user's profile Send private message Yahoo Messenger
shalabh1976
PostPosted: Tue Apr 04, 2006 9:53 pm    Post subject: Reply with quote

Partisan

Joined: 18 Jul 2002
Posts: 381
Location: Gurgaon, India

If you want to avoid Java altogether you can try accessing the timestamp functions available with various databases. Running a select clause on those will give you the desired values. This may have a performance issue compared to other methods mentioned in the post.
_________________
Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
jbanoop
PostPosted: Wed Apr 05, 2006 6:10 am    Post subject: Reply with quote

Chevalier

Joined: 17 Sep 2005
Posts: 401
Location: SC

And if the DB is on another machine you may end up with a dfferent time which may lead to inconsistencies.
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » current time
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.