View previous topic :: View next topic |
Author |
Message |
psmadhusudhan Beginner

Joined: 28 Nov 2006 Posts: 143 Topics: 48
|
Posted: Wed Jul 25, 2007 10:58 pm Post subject: Query for concatenation of columns and matching |
|
|
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 |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Thu Jul 26, 2007 12:32 am Post subject: |
|
|
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 |
|
 |
psmadhusudhan Beginner

Joined: 28 Nov 2006 Posts: 143 Topics: 48
|
Posted: Thu Jul 26, 2007 4:06 am Post subject: |
|
|
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 |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Thu Jul 26, 2007 4:25 am Post subject: |
|
|
Why not play with Sivaraj's idea and try to char the second field - that is where the error is pointing... |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12380 Topics: 75 Location: San Jose
|
Posted: Thu Jul 26, 2007 6:55 am Post subject: |
|
|
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 |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Thu Jul 26, 2007 8:55 am Post subject: |
|
|
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.  _________________ Cheers
Sivaraj S
'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity' |
|
Back to top |
|
 |
psmadhusudhan Beginner

Joined: 28 Nov 2006 Posts: 143 Topics: 48
|
Posted: Sun Jul 29, 2007 11:37 pm Post subject: |
|
|
Kolusu
Thank u very much. The problem is solved.  _________________ Thanks
Madhu Sudhan |
|
Back to top |
|
 |
|
|