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 

Query for concatenation of columns and matching

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


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Wed Jul 25, 2007 10:58 pm    Post subject: Query for concatenation of columns and matching Reply with quote

Hi

I have two tables
NUDM6.TDMZTPC
NUDM6.TDMZTPL

These two tables contain following columns
NUDM6.TDMZTPC: ZTP_BUS_TRAN_IDFR(CHAR(50)), ZTP_MIA_KEYDECIMAL(15,0).
NUDM6.TDMZTPL: ZTP_BUS_TRAN_IDFR(CHAR(50)), ZTP_MIA_KEYDECIMAL(15,0)

Now treat the combination of ZTP_BUS_TRAN_IDFR, ZTP_MIA_KEY columns in table TDMZTPC as COMB1 and table TDMZTPL as COMB2. Means combination of these columns should be treated as single value.

Now I need the fetch the rows from NUDM6.TDMZTPL TABLE where COMB2 is not in COMB1.

Following are the Input tables and Result table
Code:

TDMZTPL       ZTP_BUS_TRAN_IDFR                ZTP_MIA_KEY
TRA010014819  2007-05-18-14.10.42.7819300000   15695
TRA010014824  2007-07-18-13.17.21.479188       15695
TRA010014826  2007-07-18-13.11.07.631790       15695
TRA010016990  2007-05-23-14.03.19.7234390000   15695
TRA010016990  2007-05-23-14.03.19.7234390000   15695
TRA030001275  2007-05-31-08.47.03.7727890000   15695


Code:

TDMZTPC       ZTP_BUS_TRAN_IDFR                ZTP_MIA_KEY
TRA010014819  2007-05-18-14.10.42.7819300000   15695
TRA010014824  2007-07-18-13.17.21.479188       15696
TRA010014826  2007-07-18-13.11.07.631791       15695
TRA010016990  2007-05-23-14.03.19.7234390000   15695
TRA010016990  2007-05-23-14.03.19.7234390000   15695
TRA030001275  2007-05-31-08.47.03.7727890000   15700


Code:

TRA010014824  2007-07-18-13.17.21.479188       15695
TRA010014826  2007-07-18-13.11.07.631790       15695
TRA030001275  2007-05-31-08.47.03.7727890000   15695

Can anybody please help me in getting this result using a query in SPUFI.

I had initially tried of conacetaning columns of one table using "||" but I am gettin following error
SQLCODE = -171, ERROR: THE DATA TYPE, LENGTH, OR VALUE OF ARGUMENT 2
OF || IS INVALID

Can anybody please help me in getting this result using a query in SPUFI.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Thu Jul 26, 2007 12:32 am    Post subject: Reply with quote

Madhu,
When you concatenate the timestamp with some other field you need to convert the Timestamp as String , i suppose you are missing that. That is the reason for -171.

Just put
Code:
char(time_stmp_fld) || field_2
,this will solve your problem.

Hope this will solve your problem.
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Thu Jul 26, 2007 4:06 am    Post subject: Reply with quote

Hi shivaraj

I think you didnt see the data types of the columns. It is not timestamp, it is character char(50). Could you try again and let me no.
_________________
Thanks
Madhu Sudhan
Back to top
View user's profile Send private message
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Thu Jul 26, 2007 4:25 am    Post subject: Reply with quote

Why not play with Sivaraj's idea and try to char the second field - that is where the error is pointing...
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12380
Topics: 75
Location: San Jose

PostPosted: Thu Jul 26, 2007 6:55 am    Post subject: Reply with quote

psmadhusudhan,

You do NOT have to concatenate the char and decimal column to compare the values. Just use both columns in the where clause and you will get the desired results

try this

Code:

SELECT *                                                                 
  FROM TABLE1                                                               
 WHERE (ZTP_BUS_TRAN_IDFR,ZTP_MIA_KEY) NOT IN (SELECT ZTP_BUS_TRAN_IDFR 
                                                     ,ZTP_MIA_KEY       
                                                 FROM TABLE2)         
                                                 ;

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
s_shivaraj
Beginner


Joined: 21 Sep 2004
Posts: 140
Topics: 14
Location: Chennai, India

PostPosted: Thu Jul 26, 2007 8:55 am    Post subject: Reply with quote

psmadhusudhan,
Sorry i didnt see the field description. Yes you have to change the other field ZTP_MIA_KEYDECIMAL as CICS Guy pointed.

But Kolusu idea looks pretty easy. Very Happy
_________________
Cheers
Sivaraj S

'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity'
Back to top
View user's profile Send private message AIM Address
psmadhusudhan
Beginner


Joined: 28 Nov 2006
Posts: 143
Topics: 48

PostPosted: Sun Jul 29, 2007 11:37 pm    Post subject: Reply with quote

Kolusu

Thank u very much. The problem is solved. Smile
_________________
Thanks
Madhu Sudhan
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