Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing image file to database?

Status
Not open for further replies.

Einstein47

Programmer
Nov 29, 2001
737
0
0
US
I am trying to store an image to an Informix database. But no matter what I try I can't get it to work with simple SQL.

I have done a very simple proof of concept - what am I doing wrong?
Code:
CREATE TEMP TABLE tmpimg1 (id serial (101) primary key, pic byte) WITH NO LOG;
CREATE TEMP TABLE tmpimg2 (id serial (101) primary key, pic blob) WITH NO LOG;
CREATE TEMP TABLE tmpimg3 (id serial (101) primary key, pic clob) WITH NO LOG;

insert into tmpimg1 values (0,Filetoblob("C:\dev\draft.gif","client","tmpimg1","pic"));
insert into tmpimg1 (id,pic) values ( 0, Filetoblob( "C:\dev\draft.gif", "client") ) ;
insert into tmpimg1 values (0,Filetoblob("/tmp/draft.gif","client","tmpimg1","pic"));
insert into tmpimg1 values (0,Filetoblob('/tmp/draft.gif','server',"tmpimg1","pic"));

insert into tmpimg2 values (0,Filetoblob("C:\dev\draft.gif","client","tmpimg2","pic"));
insert into tmpimg2 (id,pic) values ( 0, Filetoblob( "C:\dev\draft.gif", "client") ) ;
insert into tmpimg2 values (0,Filetoblob("/tmp/draft.gif","client","tmpimg2","pic"));
insert into tmpimg2 values (0,Filetoblob('/tmp/draft.gif','server',"tmpimg2","pic"));

insert into tmpimg3 values (0,Filetoclob("C:\dev\draft.gif","client","tmpimg3","pic"));
insert into tmpimg3 (id,pic) values ( 0, Filetoclob( "C:\dev\draft.gif", "client") ) ;
insert into tmpimg3 values (0,Filetoclob("/tmp/draft.gif","client","tmpimg3","pic"));
insert into tmpimg3 values (0,Filetoclob('/tmp/draft.gif','server',"tmpimg3","pic"));

drop table tmpimg1;
drop table tmpimg2;
drop table tmpimg3;

I keep getting errors on every single insert line (I try running them individually). But I still can't seem to figure out what I am doing wrong.

Any suggestions?

Einstein47
“Evil abounds when good men do nothing.“ - Nelson R.
[[]Starbase47.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top