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 > CLOB equivalent in 9.2.5

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-08-09, 04:31
krishnay6666 krishnay6666 is offline
Registered User
 
Join Date: May 2009
Posts: 2
Question CLOB equivalent in 9.2.5

i am a novice to db2.i need your help in finding the equivalent of CLOB of db2 7.2.4 in db2 9.1.4 with is used to convert clob from varchar.(i.e Hex to char).
Reply With Quote
  #2 (permalink)  
Old 05-08-09, 09:05
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
It is still there - nothing has changed in this respect.

VARCHAR is a text string and so is CLOB. I am not sure what you mean with "Hex to char".
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 05-08-09, 10:52
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
I guessed that the question was came from the added statement in DB2 V9.

IBM® DB2 Universal Database™ SQL Reference Volume 1 Version 8.2
Quote:
CLOB ( character-string-expression[, integer] )

The schema is SYSIBM.

The CLOB function returns a CLOB representation of a character string type.
In a Unicode database, if a supplied argument is a graphic string,
it is first converted to a character string before the function is executed.

character-string-expression
An expression that returns a value that is a character string.

...
DB2 Version 9 for Linux, UNIX, and Windows SQL Reference Volume 1
Quote:
...

character-string-expression
An expression that returns a value that is a character string.
The expression cannot be a character string defined as FOR BIT DATA (SQLSTATE 42846).

...
Reply With Quote
  #4 (permalink)  
Old 05-09-09, 01:39
krishnay6666 krishnay6666 is offline
Registered User
 
Join Date: May 2009
Posts: 2
my query is like select clob($some_entry) from schema.table where some_condition.earliar we used this query in 9.1.5 where it is working fine.now while executing the same command in 9.2.4 it is giving the following error.
SQL0461N "A value with data type "SYSIBM.VARCHAR FOR BIT DATA" cannot be cast to type "SYSIBM.CLOB" SQLSTATE=42846


thank you very much for your respose
Reply With Quote
  #5 (permalink)  
Old 05-09-09, 03:15
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
You may want to see this UDF written by Stolze.
UDF to convert BLOB to CLOB
Reply With Quote
  #6 (permalink)  
Old 05-09-09, 07:04
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The error is clear: you have binary data and try to interpret it as textual/character data. That's typically not a good idea because character data has code pages associated and that implies conversions if, for example, DB2 stores the data in Unicode while your application uses EBCDIC. You have a very good chance that you get garbage data.

So I would argue that 9.1.5 had a bug by not preventing such a cast and this problem is fixed in 9.2.4.

You may consider casting the VARCHAR FOR BIT DATA binary data to a BLOB (binary LOB) instead.
__________________
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