how to insert blob data i开发者_StackOverflow社区nto oracle xe from delphi 7 (ado component)
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
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.
精彩评论