Subject Re: [firebird-support] How do load a BLOB file using an Update query
Author Martijn Tonies (Upscene Productions)
Hi Craig,


>I have been using "LoadFromFile" in my Delphi apps to load a pdf file into
>my Firebird databases. However, I need to replicate this using an update
>query.
>The code below was my first attempt. Using IBOjects within Delphi
> qryUpdateManifestBLOB.SQL.Clear;
> qryUpdateManifestBLOB.SQL.Add('UPDATE');
> qryUpdateManifestBLOB.SQL.Add('w_shipments');
> qryUpdateManifestBLOB.SQL.Add('SET');
> qryUpdateManifestBLOB.SQL.Add('w_shipments.US_manifest_doc =');
> qryUpdateManifestBLOB.SQL.Add('LoadFromFile');

Well, this obviously won't work, because whatever is in the .SQL property,
is executed by the Firebird database engine. And that engine cannot execute
Delphi code.

Use a parameter:
SQL.Add('SET myblobcol = :newblob');

and of course the primary key stuff.

Call:
qryUpdateManifestBLOB.Prepare;
qryUpdateManifestBLOB.ParamByName('newblob').LoadFromFile
qryUpdateManifestBLOB.ExecSQL;

>which Firebird did not like because "LoadToFile" is an unknown function.

See above.


With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!