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 » Making a STRING Field PACKED

Post new topic  Reply to topic
 Making a STRING Field PACKED « View previous topic :: View next topic » 
Author Message
lung
PostPosted: Fri Feb 06, 2004 6:45 pm    Post subject: Making a STRING Field PACKED Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

Hi all.

I need to make a conversion from a String field to a packed field. In other words, for example if FieldA is 'ABC', I want FieldB to be x'ABC'. How can I accomplish this?

Thanks!
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
EddieA
PostPosted: Fri Feb 06, 2004 7:04 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Are you saying that the input field is the actual hex you want, but in characters. If so, then ABC is invalid because you would need an even number of charaters.

Or do you want to convert the characters ABC into their hex equivalent.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
lung
PostPosted: Fri Feb 06, 2004 7:48 pm    Post subject: Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

Thanks for the prompt reply.

I want it to be in actual hex, in characters. Thus 'ABC' would become x'0ABC' (zero in front, since it is in hex format)

Of course there won't be any instance where the character i want to convert is later than the character F, since it is not supported in hex format.

To put the matter in simpler terms, let's just assume I want to convert '123456' in STRING to x'123456' (hex), which would turn up as '4V' in STRING.

I could use the code

SET Field2 = x'123456'

But what if the value I want to set is in a variable?

Hope you get what I mean here.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
EddieA
PostPosted: Fri Feb 06, 2004 10:56 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

In which case, a CAST(string AS BLOB) should do it.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
kspranava
PostPosted: Sun Feb 08, 2004 6:14 pm    Post subject: Concatenate Reply with quote

Centurion

Joined: 27 Apr 2003
Posts: 124

Hi,

Did u try concatenation ? This might be silly, still if it serves ur problem then u can use it very well.

Pranava.
Back to top
View user's profile Send private message
lung
PostPosted: Sun Feb 08, 2004 10:25 pm    Post subject: Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

My mistake...
Actually, the code

SET Field2 = x'123456';

Itself doesn't work because I've declared Field2 as a STRING.

So how can I assign a hexadecimal value into a STRING?

I've tried this code here

SET Field2 = CAST(x'123456' AS CHAR);

But then Field2 ends up as 'X'123456' instead of '4V'! This really stumps me because the 'X' itself appears in the STRING! The same happens when I try to use a BLOB variable in place of the x'123456', eg.

DECLARE temp AS BLOB;
SET temp = x'123456';
SET Field2 = CAST(temp as CHAR);

Please help!

kspranava, what do you mean by using concatenation? Please provide an example if possible... Thanks!
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
kirani
PostPosted: Sun Feb 08, 2004 10:56 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Lung,
You need to use CCSID parameter in your code, for example,
Code:

DECLARE temp AS BLOB;
SET temp = x'123456';
SET Field2 = CAST(temp as CHAR CCSID InputProperties.CodedCharSetId);

_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kspranava
PostPosted: Sun Feb 08, 2004 11:37 pm    Post subject: try this... Reply with quote

Centurion

Joined: 27 Apr 2003
Posts: 124

Hi Lung,

Forget abt concatenation. Try this code.

Declare temp CHAR;
SET temp= cast(cast(strToConvert as BLOB ) as char ccsid InputProperties.CodedCharSetId);

strToConvert is the string to be converted.

Pranava.
Back to top
View user's profile Send private message
lung
PostPosted: Mon Feb 09, 2004 12:38 am    Post subject: Reply with quote

Master

Joined: 27 Aug 2002
Posts: 291
Location: Malaysia

Thanks for the replies, kirani and kspranava.

The CCSID thing works!

Problem solved.
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Making a STRING Field PACKED
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.