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 October 9th, 2006, 12:34 PM
PianoServant PianoServant is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 PianoServant User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 12 sec
Reputation Power: 0
SQL Help with long varchar field

I'm trying to write SQL that will allow me to perform a case insensitive search against a long varchar field. This is a vendor supplied database, so changing the database isn't an option. UPPER/UCase and LOWER/LCase do not work because it is a long varchar field. Does anyone have any suggestions?

Reply With Quote
  #2  
Old October 17th, 2006, 09:04 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 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 14 h 11 m 13 sec
Reputation Power: 22
What happens when you try the UCASE/LCASE functions against substrings you KNOW should be found? Is the data in the varchar field in mixed case? What about the search arg? Cannot say that I have done this or that I have not! Could you do:
where (SomeColumn =BLAH OR SomeColumn = blah or SomeColumn = Blah)?

fv




Quote:
Originally Posted by PianoServant
I'm trying to write SQL that will allow me to perform a case insensitive search against a long varchar field. This is a vendor supplied database, so changing the database isn't an option. UPPER/UCase and LOWER/LCase do not work because it is a long varchar field. Does anyone have any suggestions?
__________________
...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
  #3  
Old October 18th, 2006, 07:59 AM
PianoServant PianoServant is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 PianoServant User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 12 sec
Reputation Power: 0
When I try UCASE/LCASE it fails. I get an error message that states "No function or procedure was found with the specified name (UCASE) and compatible arguments." VENDORERRORCODE -440, SQLSTATE 42884

UCASE/LCASE work fine on all other fields - just not LONG VARCHAR.

And yes - the data can be mixed case. I wouldn't want to search for every possible upper/lower combination. If the search was for "ONStor", I would have to perform 722 different comparisons (from "onstor" to "ONSTOR" and everything in between).







Quote:
Originally Posted by fractalvibes
What happens when you try the UCASE/LCASE functions against substrings you KNOW should be found? Is the data in the varchar field in mixed case? What about the search arg? Cannot say that I have done this or that I have not! Could you do:
where (SomeColumn =BLAH OR SomeColumn = blah or SomeColumn = Blah)?

fv
Comments on this post
neodaba disagrees: "onstor" would have 64 (2^6) permutations of upper/lower case mixed spellings

Reply With Quote
  #4  
Old October 18th, 2006, 01:21 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 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 14 h 11 m 13 sec
Reputation Power: 22
UCASE,UPPER,LCASE, and LOWER all wotk on Varchar on both Z/os and UDB for me. Could be a limitation on LONG VARCHAR?

Can you do:
UCASE(VARCHAR(mycolumn))
?

fv



Quote:
Originally Posted by PianoServant
When I try UCASE/LCASE it fails. I get an error message that states "No function or procedure was found with the specified name (UCASE) and compatible arguments." VENDORERRORCODE -440, SQLSTATE 42884

UCASE/LCASE work fine on all other fields - just not LONG VARCHAR.

And yes - the data can be mixed case. I wouldn't want to search for every possible upper/lower combination. If the search was for "ONStor", I would have to perform 722 different comparisons (from "onstor" to "ONSTOR" and everything in between).

Reply With Quote
  #5  
Old October 18th, 2006, 01:51 PM
PianoServant PianoServant is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 PianoServant User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 12 sec
Reputation Power: 0
It was a good thought..but it doesn't work. The reason the field is LONG VARCHAR is because of the length. Converting it to VARCHAR truncates part of the field and makes the "search" meaningless. Nice try though....

Quote:
Originally Posted by fractalvibes
UCASE,UPPER,LCASE, and LOWER all wotk on Varchar on both Z/os and UDB for me. Could be a limitation on LONG VARCHAR?

Can you do:
UCASE(VARCHAR(mycolumn))
?

fv

Reply With Quote
  #6  
Old October 19th, 2006, 09:23 AM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 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 14 h 11 m 13 sec
Reputation Power: 22
Hmm - max size of a varchar is 32,672.
Max size of a long varchar is 32,700. Not a lot of difference.
What on earth are you storing that has to be so large? he entire text of "War and Peace"? Seems like a rather unmanagable "chunk" of data....

fv



Quote:
Originally Posted by PianoServant
It was a good thought..but it doesn't work. The reason the field is LONG VARCHAR is because of the length. Converting it to VARCHAR truncates part of the field and makes the "search" meaningless. Nice try though....

Reply With Quote
  #7  
Old October 19th, 2006, 09:46 AM
PianoServant PianoServant is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 4 PianoServant User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 17 m 12 sec
Reputation Power: 0
It's a vendor application - I'm just trying to write a mini-app to present the information in a user-friendly format. The field is used to store all comments made regarding a particular issue.

Quote:
Originally Posted by fractalvibes
Hmm - max size of a varchar is 32,672.
Max size of a long varchar is 32,700. Not a lot of difference.
What on earth are you storing that has to be so large? he entire text of "War and Peace"? Seems like a rather unmanagable "chunk" of data....

fv

Reply With Quote
  #8  
Old October 19th, 2006, 09:57 AM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 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 14 h 11 m 13 sec
Reputation Power: 22
I would propose that such is a horrible,horrible design; but nothing you can do about their foolishness....

I there any way you can pull the content of this field out in manageble-sized "chunks"? Anything to delimit one comment from the next? If so, so might can build your own recordset or other such data structure and search that....just a wild thought.

fv


Quote:
Originally Posted by PianoServant
It's a vendor application - I'm just trying to write a mini-app to present the information in a user-friendly format. The field is used to store all comments made regarding a particular issue.

Reply With Quote
  #9  
Old November 2nd, 2006, 09:21 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,829 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 5 m 8 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
In a worse case scenario you could create a summary table or a view of your current table splitting the contents of the long varchar field into two seperate fields so that they could be cast into varchar without damaging them.
Then do your searches against the view or summary table.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > SQL Help with long varchar field


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


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





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