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 > insert data in fields clob/blob.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-11, 13:52
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 282
insert data in fields clob/blob.

Hi Colleagues,

somebody can say me how to insert data in fields clob and blob, I have a table with this structure,

a integer,
b char,
c char,
d clob,
e blob

I need insert, read,update or delete data in this table.

thank you for you help.
Reply With Quote
  #2 (permalink)  
Old 01-27-11, 14:53
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Just use the INSERT statement.

The real question is how you get the data into your application. If you want to use the DB2 CLP for the INSERT, you can't specify a file name because that would just be a string. DB2 has to know that the string is a file and the file content has to be read. So you'll need some sort of function:
Code:
INSERT INTO ... VALUES ( ..., readfile('filename'), ...);
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 01-27-11, 15:58
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
If you just have a small number of rows to update manuualy, then there are some freeware Windows apps that do this (loads contents windows file into a DB2 lob column). I used a program like this about 3 years ago that I found on the Internet. I don't remember the name of the program, but maybe you can find one like it.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #4 (permalink)  
Old 01-28-11, 06:17
georgipa georgipa is offline
Registered User
 
Join Date: Dec 2002
Location: Madrid - Spain
Posts: 282
Hi Colleagues,

I am executing this command

db2 "insert into ARTISTS values (1,'Esto es una Prueba de Insert','P',readfile('/Pantallazo.png'), readfile('/Pantallazo.png') ";

DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0440N No authorized routine named "READFILE" of type "FUNCTION" having
compatible arguments was found. SQLSTATE=42884

Somebody can explain me how to execute the command correct without errors.

Thank you for you help.
Reply With Quote
  #5 (permalink)  
Old 01-28-11, 10:09
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Knut expects you to create a UDF (using C) called readfile that reads a file. He wrote an article about how to create one a long time ago (maybe on IBM website Develperworks). It does not come with DB2.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #6 (permalink)  
Old 01-31-11, 07:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Marcus is right. One example how to write such a UDF can be found here: Making Operating System Calls from SQL
__________________
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