DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old July 29th, 2004, 08:54 AM
maulik09 maulik09 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 maulik09 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
not like predicate

select
rpt.id as rpt_id, dtl.id as dtl_id,
rpt.cd as rpt_li, dtl.cd as dtl_li,
rpt.cd_code as rpt_code,dtl.cd_code as dtl_code,
rpt.cd_summ as rpt_summ,dtl.cd_ind as dtl_ind

from udbadm.tab_dtl dtl,udbadm.tab_rpt rpt
where rpt.id = dtl.id
and rpt.dt = dtl.dt
and rpt.cd = dtl.cd
and rpt.cd_code = dtl.cd_code
and dtl.id ='00244407'
and rpt.cd_summ not like '''%'||dtl.cd_ind||'%''';

rpt.cd_summ not like '''%'||dtl.cd_ind||'%'''
The above statement will be
1st iteration) ABC,CDFG,TER not like '%TER%'
2nd iteration)ABC,CDFG,TER not like '%ABC%'
3rd iteration)ABC,CDFG,TER not like '%CDFG%'

But that statement gives this error:
[IBM][CLI Driver][DB2/6000] SQL0132N A like or posstr scalar function is not valid because the first operation is not a string expression or the second is not a string.

Please help me put with this. Thanks a lot in advance.

I tired to cast the columnn names but didn't work.

-MS

Reply With Quote
  #2  
Old July 29th, 2004, 01:01 PM
dcaillouet's Avatar
dcaillouet dcaillouet is offline
Big Endian
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: May 2001
Location: Fly-over country
Posts: 1,173 dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level)dcaillouet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 16 h 29 m 5 sec
Reputation Power: 24
In order to put a single quote in an SQL statement, you might want to use the hexadecimal notation X'27'.

If you did a select like the following, you should see the string you're looking for:

SELECT X'27' || '%' || cd_ind || '%' || X'27'
FROM udbadm.tab_dtl

This solves one problem, but gives you another. The DB2 documentation for the LIKE predicate says that the left-hand side of the LIKE can be:

# a constant
# a special register
# a host variable (including a locator variable or a file reference variable)
# a scalar function
# a large object locator
# a column name
# an expression concatenating any of the above

But to the right of the LIKE you can only have:

# a constant
# a special register
# a host variable
# a scalar function whose operands are any of the above
# an expression concatenating any of the above

Do you notice what's missing from the second list? I'll give you a hint. It's what you're trying to use: A column name. I've never had to use a query like you're trying to do so I'm not sure how to solve it. Maybe using a SCALAR function of some kind will cast the column into something that LIKE will accept. If you get it to work, let us know for future reference.

Reply With Quote
  #3  
Old July 29th, 2004, 02:02 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 630 fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 11 h 21 m 37 sec
Reputation Power: 21
I had a situation like that where a policy number was stored
on one table, and on another table it was stored with an extra digit (some type of suffix code...)

They corrected the problem, but was able to join using this method:

AND LTRIM(RTRIM(A.POL_NBR_TXT))= SUBSTR(E.BNFT_NBR_TXT,1,LENGTH(RTRIM(LTRIM(A.POL_NBR_TXT))))

not sure that this would work in all instances...

fv
__________________
...because that is the way we have always done it. We've been doing it like that for 80 Years! (How do we change that mindset?)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > not like predicate


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway