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 » adding leading zeroes in esql

Post new topic  Reply to topic
 adding leading zeroes in esql « View previous topic :: View next topic » 
Author Message
chenna.hari
PostPosted: Wed May 15, 2013 9:42 pm    Post subject: adding leading zeroes in esql Reply with quote

Centurion

Joined: 21 Mar 2009
Posts: 103

Hi,

I need to generate the output always 3 characters, with adding leading 0's if the length of the input is less than 3 characters.

eg. input is 1, then output should be 001
input is 12, then output should be 012
input is 123, then output should be 123.

Can any one suggest the best way to do this in esql.

Regards,
Hari.
Back to top
View user's profile Send private message
marko.pitkanen
PostPosted: Wed May 15, 2013 9:46 pm    Post subject: Reply with quote

Chevalier

Joined: 23 Jul 2008
Posts: 440
Location: Jamsa, Finland

Have you modeled the output message?
Back to top
View user's profile Send private message Visit poster's website
PEPERO
PostPosted: Wed May 15, 2013 9:47 pm    Post subject: Reply with quote

Disciple

Joined: 30 May 2011
Posts: 177

try this way :
Set strWithleftPaddedZeros = SUBSTRING('000' from 1 for (3 - LENGTH(originString))) || originString;
you could also use the 'RIGHT' command.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Wed May 15, 2013 9:51 pm    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

use CAST with FORMAT
Back to top
View user's profile Send private message
chenna.hari
PostPosted: Wed May 15, 2013 9:52 pm    Post subject: Reply with quote

Centurion

Joined: 21 Mar 2009
Posts: 103

No, Ouput message is not modeled.
Back to top
View user's profile Send private message
kash3338
PostPosted: Thu May 16, 2013 10:01 pm    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

You can make use of OVERLAY function. Thats a easy way of doing this.
Back to top
View user's profile Send private message Send e-mail
dogorsy
PostPosted: Thu May 16, 2013 10:10 pm    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

kash3338 wrote:
You can make use of OVERLAY function. Thats a easy way of doing this.


I cannot see how overlay is easier than

CAST((cast input_field as integer) as char format '000');

or RIGTH('000'||input_field,3);
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

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