BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

BLOB Fields and SQL
Goto page 1, 2  Next
 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Stephen Lee-Woolf
Guest





PostPosted: Mon May 17, 2004 12:20 pm    Post subject: BLOB Fields and SQL Reply with quote



Please excuse the simplicity of this question, but I have not worked
with BLOB fields before and am completely ignorant on the subject.

I have an application that creates a .TIF file which forms the basis of
a FAX message. What I need to do is to put the graphic into the blob
field of a table (Firebird 1.5) and to be able to subsequently access it
from there.

Can someone point me in the right direction for this?

Thanks
--
Steve Lee-Woolf
Manchester,
United Kingdom

"There are 10 types of people:
Those who understand Binary,
and those who don't"
Back to top
Bill Todd (TeamB)
Guest





PostPosted: Mon May 17, 2004 12:53 pm    Post subject: Re: BLOB Fields and SQL Reply with quote



Use a parameterized INSERT statement and use the parameter object's
LoadFromFile method to assign the contents of the file to the
parameter.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Stephen Lee-Woolf
Guest





PostPosted: Mon May 17, 2004 1:16 pm    Post subject: Re: BLOB Fields and SQL Reply with quote



DOn't quite follow. ...

IBQuery1.ParamByName('BB').AsBlob := ????

In article <0ddha0hc0ub13715m3u6ntfn3rbjmh4eag (AT) 4ax (DOT) com>, [email]no (AT) no (DOT) com[/email]
says...
Quote:
Use a parameterized INSERT statement and use the parameter object's
LoadFromFile method to assign the contents of the file to the
parameter.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)


--
Steve Lee-Woolf
Manchester,
United Kingdom

"There are 10 types of people:
Those who understand Binary,
and those who don't"

Back to top
Del Murray
Guest





PostPosted: Mon May 17, 2004 3:10 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

What Bill means is ..

assuming that the tiff image is a file and that tablex has a blob column
called sometifimage ...

create a tadodataset with a command property of
insert into tablex (sometifimage) values(:tifimage) .. notice the
colon in front of "tifimage" (this is a parameter and it is referenced as
tadoquery.parameters[0].value assuming that it is the only parameter ..
they start counting at 0.
you can say in code ..
tadoquery.parameters[0].value := 'xxx' or
tadoquery.parameters[0].loadfromfile( filename, etc) // check the docs
for all the parms for "loadfromfile"

this method will read the data from file for you and put it in the value of
the first parameter . you then only need "post" the tadodataset



Back to top
Stephen Lee-Woolf
Guest





PostPosted: Mon May 17, 2004 4:08 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

Nice one Del, thanks. That seems to work fine for putting the .tif into
the table, but how do I get it out (into a new file)? If I use a SELECT
query isn't the SQL parser going to get confused and try to look for the
filename as the value of the blob field?

In article <40a8d522$1 (AT) newsgroups (DOT) borland.com>,
[email]Del.Murray (AT) N_S_CreditHawk (DOT) Net[/email] says...
Quote:
What Bill means is ..

assuming that the tiff image is a file and that tablex has a blob column
called sometifimage ...

create a tadodataset with a command property of
insert into tablex (sometifimage) values(:tifimage) .. notice the
colon in front of "tifimage" (this is a parameter and it is referenced as
tadoquery.parameters[0].value assuming that it is the only parameter ..
they start counting at 0.
you can say in code ..
tadoquery.parameters[0].value := 'xxx' or
tadoquery.parameters[0].loadfromfile( filename, etc) // check the docs
for all the parms for "loadfromfile"

this method will read the data from file for you and put it in the value of
the first parameter . you then only need "post" the tadodataset





--
Steve Lee-Woolf
Manchester,
United Kingdom

"There are 10 types of people:
Those who understand Binary,
and those who don't"

Back to top
Del Murray
Guest





PostPosted: Mon May 17, 2004 4:37 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

No, you're not putting the file name into the blob, your putting the
contents of the file (load from file) into the blob. You might store the
filename in another column just for grins so that you know where it came
from, but the actual tiff will be in the column that you updated with the
loadfromfile method. Getting it out depends on what you are going to do with
it. You treat the blob data just like anyother data. You can say ...

select mytiffimage from tifftable where ImageName = 'SomeNudeChick'

Now you have the tiff in a column object of an ado object. You can do what
ever you need from there.

Got it?


Back to top
Bill Todd (TeamB)
Guest





PostPosted: Mon May 17, 2004 6:10 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

In addition to Del's excellent explanation, note that the TBlobField
field object has a SaveToFile method so you can do:

(IBDataSet1.FieldByName('TheTif') as
TBlobField).SaveToFile('c:fooatif.tif');

Note that FieldByName returns a reference to a TField so you have to
cast it to TBlobField to have access to the SaveToFile method.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Del Murray
Guest





PostPosted: Mon May 17, 2004 6:48 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

I am honored the Bill Todd thinks my explanation is excellent ... do I win
anything? :-)


Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Mon May 17, 2004 7:33 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

Del Murray wrote:
Quote:
I am honored the Bill Todd thinks my explanation is excellent ... do
I win anything? Smile

A year's worth of TeamB salary. <g>

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"True peace is not the absence of tension, but the presence of
justice." - Martin Luther King, Jr.



Back to top
Bill Todd (TeamB)
Guest





PostPosted: Mon May 17, 2004 8:03 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

I'll send you half of my next TeamB bonus check.<g>


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Del Murray
Guest





PostPosted: Mon May 17, 2004 9:05 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

I knew you guys make the big bucks .... I'll invest it in Enron stock when
it comes ;-)


Back to top
Stephen Lee-Woolf
Guest





PostPosted: Tue May 18, 2004 8:06 am    Post subject: Re: BLOB Fields and SQL Reply with quote

Got it. It's really not that difficult when you get down to it is it?

Thanks for your help Del.


In article <40a8e991 (AT) newsgroups (DOT) borland.com>,
[email]Del.Murray (AT) N_S_CreditHawk (DOT) Net[/email] says...
Quote:
No, you're not putting the file name into the blob, your putting the
contents of the file (load from file) into the blob. You might store the
filename in another column just for grins so that you know where it came
from, but the actual tiff will be in the column that you updated with the
loadfromfile method. Getting it out depends on what you are going to do with
it. You treat the blob data just like anyother data. You can say ...

select mytiffimage from tifftable where ImageName = 'SomeNudeChick'

Now you have the tiff in a column object of an ado object. You can do what
ever you need from there.

Got it?




--
Steve Lee-Woolf
Manchester,
United Kingdom

"There are 10 types of people:
Those who understand Binary,
and those who don't"

Back to top
Stephen Lee-Woolf
Guest





PostPosted: Tue May 18, 2004 8:07 am    Post subject: Re: BLOB Fields and SQL Reply with quote

Thanks Bill. I'm getting the hang of this now!

In article <brvha0t6ti3tjm0k519s07i0133hflupfk (AT) 4ax (DOT) com>, [email]no (AT) no (DOT) com[/email]
says...
Quote:
In addition to Del's excellent explanation, note that the TBlobField
field object has a SaveToFile method so you can do:

(IBDataSet1.FieldByName('TheTif') as
TBlobField).SaveToFile('c:fooatif.tif');

Note that FieldByName returns a reference to a TField so you have to
cast it to TBlobField to have access to the SaveToFile method.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)


--
Steve Lee-Woolf
Manchester,
United Kingdom

"There are 10 types of people:
Those who understand Binary,
and those who don't"

Back to top
Stephen Lee-Woolf
Guest





PostPosted: Tue May 18, 2004 9:39 am    Post subject: Re: BLOB Fields and SQL Reply with quote

Bill

The only problem with that is that my D7 installation doesn't appear to
recognise the AsTBlobField casting. Is there an additional unit I need
to use in my project?


In article <brvha0t6ti3tjm0k519s07i0133hflupfk (AT) 4ax (DOT) com>, [email]no (AT) no (DOT) com[/email]
says...
Quote:
In addition to Del's excellent explanation, note that the TBlobField
field object has a SaveToFile method so you can do:

(IBDataSet1.FieldByName('TheTif') as
TBlobField).SaveToFile('c:fooatif.tif');

Note that FieldByName returns a reference to a TField so you have to
cast it to TBlobField to have access to the SaveToFile method.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)


--
Steve Lee-Woolf
Manchester,
United Kingdom

"There are 10 types of people:
Those who understand Binary,
and those who don't"

Back to top
Bill Todd (TeamB)
Guest





PostPosted: Tue May 18, 2004 1:34 pm    Post subject: Re: BLOB Fields and SQL Reply with quote

No. All you need is the DB unit. Show us the line that fails and the
full text of the error message.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.