user578332
user578332

Reputation: 345

delphi oracle blob

how to insert blob data into oracle xe from delphi 7 (ado component)

Upvotes: 4

Views: 2570

Answers (2)

user160694
user160694

Reputation:

Be aware that Oracle has a peculiar way to handle LOBs. It uses "LOB locators" (a sort of handles) to perform operations on LOBs. An INSERT returns a LOB locator that is then used to fill the LOB, for example. That operation could be performed "behind the scenes" by the driver/library used to access Oracle, or may require some coding.

Upvotes: 0

RRUZ
RRUZ

Reputation: 136401

Check these samples using a TAdoQuery component.

loading the data directly from a file

 ADOQuery1.Parameters.AddParameter.Name:='Param1';
 ADOQuery1.Parameters.ParamByName('Param1').LoadFromFile('yourfilename',ftBlob);
 ADOQuery1.SQL.Add('INSERT INTO TableName (FieldName) VALUES (:Param1)');
 ADoQuery1.ExecSQL;

using a Stream to load the data

 ADOQuery1.Parameters.AddParameter.Name:='Param1';
 ADOQuery1.Parameters.ParamByName('Param1').LoadFromStream(AStream,ftBlob);
 ADOQuery1.SQL.Add('INSERT INTO TableName (FieldName) VALUES (:Param1)');
 ADoQuery1.ExecSQL;

you must be aware which the Microsoft Oracle oledb driver is not compatible with blob fields try instead using the Oracle OLEDB provider.

As final advice if you can, try using another components to connect to ORACLE like dbexpress, ANYDAC or the ODAC components

Upvotes: 6

Related Questions