IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

I have doubt in LIKE statement in DB2 program


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raveepisini

New User


Joined: 23 Nov 2010
Posts: 1
Location: chennai

PostPosted: Mon Aug 13, 2012 2:51 am
Reply with quote

Hi

Please find below statement
SELECT A.ACCOUNT, A.SECURITYID
FROM TABLE1 A, TABLE2 B
WHERE A.TABLE1_ACCOUNT SUBSTR(1,3) = B.TABLE2_IBD
WITH UR;

In the table1 it contains almost 54millons records
Int the table 2 it contains only 1000 records..
Because of above select statement my job running almost 10mins as elapse time and 4min cpu time.. I know in the like statment we can concatenate 2table_field to get value. Please provide me how to do..

Table1_account field size is 15
Table2_ibd file size is 3
I want to write it as
SELECT A.ACCOUNT, A.SECURITYID
FROM TABLE1 A, TABLE2 B
WHERE A.TABLE1_ACCOUNT LIKE (B.TABLE2_IBD)
WITH UR;

Please let me know how to do that
[/code]
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 13, 2012 5:17 am
Reply with quote

Code:
WHERE A.TABLE1_ACCOUNT SUBSTR(1,3) = B.TABLE2_IBD


until you can be accurate and honest with us,
(the above sql in not proper syntax)
we are wasting our time even looking at this.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Aug 13, 2012 8:07 am
Reply with quote

Hello and welcome to the forum,

Suggest you post the execution of the query you posted.

As DBZ posted, the syntax is not proper. . .
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Mon Aug 13, 2012 2:58 pm
Reply with quote

You can't use like, but you might want to try something like this :
Code:
WHERE A.TABLE1_ACCOUNT between B.TABLE2_IBD || x'00' and B.TABLE2_IBD || x'FF'
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Aug 13, 2012 7:43 pm
Reply with quote

Using the same strange syntax, I would try:
Code:
WHERE A.TABLE1_ACCOUNT SUBSTR(1,3) IN (SELECT DISTINCT TABLE2_IBD FROM TABLE2)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top