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 » Padding a field

Post new topic  Reply to topic
 Padding a field « View previous topic :: View next topic » 
Author Message
EnOne
PostPosted: Thu Oct 06, 2005 6:53 am    Post subject: Padding a field Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

One of the common things I am working on it Justifying and Padding within eSQL. There are a few ways to do this there are four examples below. For the example I'm using right justify left pad with zeros.


<InputNumber>123456</InputNumber>
A.
Code:
DECLARE InputNumber CHAR;
SET InputNumber = CAST(InputBody.XML.InputNumber AS CHAR);
WHILE LENGTH(InputNumber) < 10 DO
    SET InputNumber = '0' || InputNumber;
END WHILE;

B.
Code:
DECLARE InputNumber CHAR;
SET InputNumber = SUBSTRING('0000000000' FROM 1 FOR (10-LENGTH(InputNumber))) || CAST(InputBody.InputNumber AS CHAR);

C.
Code:
DECLARE InputInteger INT;
DECLARE InputNumber CHAR;
SET InputInteger = 10000000000 + InputBody.InputNumber;
SET InputNumber = SUBSTRING(CAST(InputInteger AS CHAR) FROM 2 FOR 10);

D.
Code:
SET InputNumber = RIGHT('0000000000' || CAST(InputBody.InputNumber AS CHAR),10)


Does anyone know a best practice for which way is faster/more reliable or is there another way.
Back to top
View user's profile Send private message
Empeterson
PostPosted: Thu Oct 06, 2005 6:58 am    Post subject: Reply with quote

Centurion

Joined: 14 Apr 2003
Posts: 125
Location: Foxboro, MA

There is an OVERLAY function which which can accomplish this. Refer to the esql manual for exact syntax.
_________________
IBM Certified Specialist: MQSeries
IBM Certified Specalist: Websphere MQ Integrator
Back to top
View user's profile Send private message Send e-mail AIM Address
EnOne
PostPosted: Thu Oct 06, 2005 7:34 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

E.
Code:
DECLARE InputLength INT;
DECLARE InputNumber CHAR;
SET InputLength = LENGTH(InputRoot.InputNumber);
SET InputNumber = OVERLAY('0000000000'  PLACING InputRoot.InputNumber FROM (10-InputLength) FOR InputLength);
Back to top
View user's profile Send private message
Empeterson
PostPosted: Thu Oct 06, 2005 8:52 am    Post subject: Reply with quote

Centurion

Joined: 14 Apr 2003
Posts: 125
Location: Foxboro, MA

What are you doing with InputNumber? Is that going to be mapped to a field that is defined in a message set?
_________________
IBM Certified Specialist: MQSeries
IBM Certified Specalist: Websphere MQ Integrator
Back to top
View user's profile Send private message Send e-mail AIM Address
EnOne
PostPosted: Thu Oct 06, 2005 9:24 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 100
Location: Kansas City

They are receiving the number from me in XML format. The Input is either MRM or XML.

<Parent>
<OutputNumber>0000123456</OutputNumber>
</Parent>
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 » Padding a field
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.