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 > convert blob to clob

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-04, 03:20
fadace fadace is offline
Registered User
 
Join Date: Nov 2002
Location: Switzerland
Posts: 523
Thumbs down convert blob to clob

How to convert a blob field to a clob field ?

RDBMS: DB2-400 R5V2

The alter table doesn't run.
The insert select failed with conversion problem.
__________________
F. Celaia
DBA Sybase/DB2/Oracle/MS-SQL
Reply With Quote
  #2 (permalink)  
Old 07-16-04, 04:17
Tank Tank is offline
Registered User
 
Join Date: Feb 2004
Location: Copenhagen
Posts: 220
Exclamation Sybase ?!

Is this DB2??

- I've never seen an error message like it
__________________
Kristian K. Hansen
Project Supervisor
National Board of Health
Reply With Quote
  #3 (permalink)  
Old 07-20-04, 04:21
fadace fadace is offline
Registered User
 
Join Date: Nov 2002
Location: Switzerland
Posts: 523
RDBMS: DB2-400 R5V2 is not the error message, it's the version. DB2 Release 5 version 2 on OS400.

If you want a repro:

Code:
create table fcelaia/t (i int, b blob(1024000)) 
insert into fcelaia/t values(1,blob('ABCDE'))
ALTER TABLE FCELAIA/T ALTER COLUMN B SET DATA TYPE CLOB ( 2048000)
=> Incompatible attribute of the column B of T in FCELAIA. (it's a conversion from a French error msg !)

Code:
ALTER TABLE FCELAIA/T ADD C CLOB ( 2048000) 
UPDATE FCELAIA/T set C=B
=> incompatible value with column datatype or value C.

Code:
UPDATE FCELAIA/T set C=clob(B)
=> The argument of the function clob is incorrect
__________________
F. Celaia
DBA Sybase/DB2/Oracle/MS-SQL
Reply With Quote
  #4 (permalink)  
Old 07-20-04, 04:28
Tank Tank is offline
Registered User
 
Join Date: Feb 2004
Location: Copenhagen
Posts: 220
Red face Now I see

Hi

Hav you tried using the Char function to convert
the binary code to Ascii chars? i.e.

update yourtable set c=char(b) ??

I'm not sure it will work, as I'm not very
much into AS400

HTH
__________________
Kristian K. Hansen
Project Supervisor
National Board of Health
Reply With Quote
  #5 (permalink)  
Old 07-20-04, 04:56
fadace fadace is offline
Registered User
 
Join Date: Nov 2002
Location: Switzerland
Posts: 523
I'm not sure it's AS400 relevant. Except the limitation of the language, the SQL behavior should be the same in any Db2 ("I have a dream !")

Code:
select char(b) from fcelaia/t
=> the argument 1 of the function char is incorrect

I'm not really surprised, because the blob/clob are storing a pointer, and not really a value. Your tip is trying to convert an address to a char.
__________________
F. Celaia
DBA Sybase/DB2/Oracle/MS-SQL
Reply With Quote
  #6 (permalink)  
Old 07-20-04, 05:58
Tank Tank is offline
Registered User
 
Join Date: Feb 2004
Location: Copenhagen
Posts: 220
Arrow Ok

Well I certainly get different error messages than you,
and I can display the ascii content of a clob in the
stout of my Korn shell - but I guess i've reached the
extent of my knowledge - hopefully someone else can help you!!
__________________
Kristian K. Hansen
Project Supervisor
National Board of Health
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