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 

DB2 Query concat operator

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


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Thu Oct 08, 2009 8:55 am    Post subject: DB2 Query concat operator Reply with quote

Hi,

I have got a db2 query where we are using CONCAT " in the query,
Code:

SELECT * FROM Table1 A, Table2 B
WHERE A.ABC= B.ABC CONCAT ''
 

The column ABC is of same datatype.

When we ran the query with and without CONCAT ", we got the same output. There was no difference in the output.

Please help me in understanding the usage of CONCAT " in the where clause. Thanks in advance!!
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Oct 08, 2009 10:44 am    Post subject: Reply with quote

waves,

You are not concatenating anything to the string. i.e you don't have any value between the quotes. So the query works same as if the concat is not there

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Fri Oct 09, 2009 6:23 am    Post subject: Reply with quote

Hello waves,

what your original query does is manipulating the access path to the data created by the DB2 optimizer.

Here a possible index access by DB2 is circumvented by transforming the equal predicate of the where clause (stage-1 processing by DB2, indexable) into a function call (stage-2 processing, not indexable). A similar manipulation for predicates on numeric values is adding 0 to the right side of the equation.

Sometimes these actions are advisable, when the structure of the contents of the column is different from the asumptions the DB2 optimizer is using (scewness of data, dependencies of one column from the values of another column in the same table, etc.)

This manipulation has nothing to do with the results of your query but only with the access path DB2 is using to get to the results.

regards
Christian
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Oct 09, 2009 10:06 am    Post subject: Reply with quote

CZerfas,

Interesting way to manipulate access path . Thanks for the info

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
waves
Beginner


Joined: 09 Nov 2006
Posts: 35
Topics: 12

PostPosted: Mon Oct 12, 2009 7:26 am    Post subject: Reply with quote

Thanks a Lot Kolusu and Christian!!!. That Really helps...
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