If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How I can to execute a Query with field BLOB with grouping?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-08-09, 14:42
gabrielatme gabrielatme is offline
Registered User
 
Join Date: Nov 2008
Posts: 8
How I can to execute a Query with field BLOB with grouping?

Hi,

How can I execute a Query with field BLOB with grouping?
Does have as converting BLOB to VARCHAR?

Thanks
Reply With Quote
  #2 (permalink)  
Old 05-08-09, 15:13
gabrielatme gabrielatme is offline
Registered User
 
Join Date: Nov 2008
Posts: 8
Example....


[db2ihrs@hrsdsvx ~]$ db2 describe table t1

Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
C1 SYSIBM BLOB 1048576 0 Yes
C2 SYSIBM INTEGER 4 0 Yes




[db2ihrs@hrsdsvx ~]$ db2 "select c1, avg(c2) c2 from t1 group by c1"
SQL0134N Improper use of a string column, host variable, constant, or
function "C1". SQLSTATE=42907


I can tested with varchar(c1)... cast(c1 as varchatr(32)) however don't work ;(
Reply With Quote
  #3 (permalink)  
Old 05-08-09, 19:10
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I don't think you can group by LOB expressions; also, the maximum length of the GROUP BY columns cannot exceed 32K. Try using SUBSTR() and VARCHAR().
Reply With Quote
  #4 (permalink)  
Old 05-09-09, 06:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
SUBSTR and VARCHAR don't work on BLOBs - only on CLOBs. What you can do is to write an external UDF that does something with the BLOB to produces a VARCHAR or INT or so. The question is what that "something" should be, and this is typically highly application-specific.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On