MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help needed to write Query

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
edkir98
Beginner


Joined: 27 Aug 2007
Posts: 102
Topics: 42
Location: Chennai

PostPosted: Wed Dec 23, 2009 5:13 am    Post subject: Help needed to write Query Reply with quote

We have a table which has columns
1) Account_number
2) MQMessage_Number
3) Sequence_Number
4) MQ_message
and some other columns.

The purpose of this table is to backup the MQ message which the program processed for replay purposes.

The account number is the account for which this message was obtained.
The MQ message number is a unique number which is generated for each message.
The length of the MQ_message column is only 2000 bytes but we could get MQ messages which is 16000 bytes long. So a message
of more than 2000 bytes will be truncated. Suppose if a message is 9000 bytes long then it would be stored in this table as 5 rows which have the same account number and MQ message number and there would be Sequence_Number 1,2,3,4 and 5.

So at any point in order to replay a message which has 2 segments i use a query like this

Code:
SELECT A.MQ_Message
CONCAT B.MQ_Message
  FROM MQ_TABLE
(SELECT Account_Number, MQMessage_Number, MQ_Message
   FROM MQ_TABLE
  WHERE Account_Number = 1234 AND MQMessage_Number = 'XYZ'
    AND Sequence_Number = 1)   AS A
LEFT OUTER JOIN
(SELECT Account_Number, MQMessage_Number, MQ_Message
   FROM MQ_TABLE
  WHERE Account_Number = 1234 AND MQMessage_Number = 'XYZ'
    AND Sequence_Number = 2)   AS A
ON A.Account_Number = B.Account_Number and A.MQMessage_Number = B.MQMessage_Number

Now the problem is that everyday i'll have to replay around 10 messages from production to test and it becomes a tedious process to first go and check the number of segments (Sequence Numbers) each message has and then write a query like the one above repeating the LEFT OUTER JOIN and the CONCAT clauses depending on the number of segments.

The MQMessage_Number is defined as SMALLINT and a bigger MQMessage_Number means the MQ message was the latest.

All i want to do is just to have a query where i could give this 10 MQMessage_Numbers (Something like in a IN Clause) and i would get the equivalent 10 complete messages.

Is it possible to write a query for this?

P.S. i am not able to write a program for this because i dont have access to bind to production tables.

Did i make my question clear?

Thanks in advance
_________________
Thanks
Back to top
View user's profile Send private message Yahoo Messenger
papadi
Supermod


Joined: 20 Oct 2009
Posts: 594
Topics: 1

PostPosted: Wed Dec 23, 2009 3:04 pm    Post subject: Reply with quote

If you post some of the "input" data and what you want as the result of this new query it may help someone help you.
_________________
All the best,

di
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group