Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How tp insert a BLOB?

652 views
Skip to first unread message

JR

unread,
Apr 11, 2001, 4:24:08 PM4/11/01
to
Hi,

I have created a simple table called "photos", with a BLOB field. That was
easy! But how do I insert a JPG-file into that field? I have searched the
help files, but haven't been able to find anything there.

I'm using DB2 UDB 7.1 om Windows 2000.

Thanks!

Jakob


Larry Menard

unread,
Apr 11, 2001, 5:33:05 PM4/11/01
to
Jakob, have you checked out the sample code in "\sqllib\samples"? The
sample database (as created by either the "db2sampl" command or the "First
Steps" tool) also has some BLOBs, and as I recall, the sample programs show
you how to manipulate them.

JR wrote:

--
Larry Menard
IBM Workstation Database (DB2) Performance Team
Defender of Geese and of all things Natural


bernd hohmann

unread,
Apr 12, 2001, 2:46:52 AM4/12/01
to
On Wed, 11 Apr 2001 22:24:08 +0200, JR wrote:

> I have created a simple table called "photos", with a BLOB field. That was
> easy! But how do I insert a JPG-file into that field? I have searched the
> help files, but haven't been able to find anything there.

either by reading the jpg file into a byte-array and move this
bytearray into the database or by using a stream.

if you're using java, my faq could help (see signature).

bernd

--
the DB2 faq: http://www.harddiskcafe.de/db2faq/index.html

Dmitry

unread,
Apr 12, 2001, 3:49:09 AM4/12/01
to
Hi,

The easiest way to insert BLOBs is to use the IMPORT command.

db2 import from photo.txt of del lobs from d:\photos\ modified by lobsinfile
commitcount 1000 insert into sample.photo

Photo.text file:

photo1.jpg
photo2.jpg
photo3.jpg

...
photoN.jpg

Best regards, Dmitry
--
http://www.ispirer.com/chyfo.html - Tool exports data to CSV flat file,
generates CREATE TABLE, CREATE INDEX scripts for IBM DB2 and scripts for DB2
IMPORT/LOAD.


"JR" <jakob...@privat.dk> wrote in message
news:9b2ei2$8o9$1...@news.inet.tele.dk...

JR

unread,
Apr 12, 2001, 10:37:07 AM4/12/01
to
Hi Dmitry,

I have tried what you suggested, but I can't get it right.

I have written:

db2 import from d:\photos.txt of del lobs from d:\data\photos\ modified by
lobsinfile
commitcount 1000 insert into rohde.photos

and I get this reply (translated): the parametres LOB-path or LOB-file can
not be used in this manner. Reason code: "1".

The photos.txt file contains the filenames of > 1700 JPG's. The table has an
ID field which is primary key with autoincrement (empty) and it contains
other fields that I have to manually fill in later. Where do I specify into
which field the photos are to be inserted? What does "commitcount 1000"
mean?

Thanks again!

Jakob

"Dmitry" <sup...@ispirer.com> wrote in message
news:9b3mmt$7lntg$1...@ID-75577.news.dfncis.de...

Dmitry

unread,
Apr 13, 2001, 6:11:09 AM4/13/01
to
Hi,

When number of columns in the text file and in the table are different, try:

db2 import from d:\photos.txt of del lobs from d:\data\photos\ modified by

lobsinfile commitcount 1000 insert into rohde.photos (photo_field)

commitcount specifies when COMMIT statement is issued.

Best regards, Dmitry
--
http://www.ispirer.com - Database migration tools and services for Oracle
and IBM DB2.


"JR" <jakob...@privat.dk> wrote in message

news:9b4ejc$im2$1...@news.inet.tele.dk...

0 new messages