Subject Re: [ib-support] A first time question...
Author Helen Borrie
At 04:57 PM 31-10-02 +1100, Kevin Friend wrote:
>This is my first question on this list - please be kind!
>
>I need to add a jpeg to a blob field in a database (firebird). I would like
>to do this using SQL, but my knowledge of SQL is not up to it!

Ahem, the whole thing is about SQL.


>I am using BCB, I can use the IBTable components to do this, but it is a
>little unreliable, and not recommended for remote servers.
>
>I can access the jpeg as a memory stream (or a file if that is better), but
>I dont know the SQL syntax to update the blob field

All that's needed is for your client application to present a blob as a
parameter for the blob field in your insert and update statements, e.g.
create simpletable (
id integer not null primary key,
jpeg blob sub_type 0);

commit;

Your dataset SQL should resolve to sthg like this:
insert into simpletable (id, jpeg)
values ( :id, :jpeg);

This isn't a Delphi/BCB support list...but as a hint, use stream methods to
move the image file into the TBlobfield (possibly IBX has its own
descendant; IB Objects has a high degree of encapsulation of blobs and
specialised blobstream classes).

If your components don't automatically assign values to the parameters (
:id, :jpeg), use the methods of the Params[] array to assign the blob. If
using the VCL (rather than custom components) use the AsString method to
pass either a string or a binary stream to a blob parameter. If you root
around the Delphi help enough, you should find enough examples to work out
a way to do this. The TJPEGImage topic seems quite well documented.

cheers,
heLen