Insert BLOB as Parameter

hschlup

Member
How can I use a simple Insert statement with a BLOB (Text Memo) as Parameter... I read a lot of a TLOBLocator, but a little example would be nice...

Thanx

Herbert
 
The help file contains the following example:
Code:
var LOB: TLOBLocator;
    Buffer: array[0..99] of Byte;
begin
  // insert into lobtable (id, lobcolumn) values (:id, empty_blob())
  //   returning lobcolumn into :lobcolumn
  with LOBQuery do
  begin
    SetVariable('id', 1);
    // Create a new BLOB (initially Null)
    LOB := TLOBLocator.Create(Session, otBLOB);
    // Assign it to the returning variable
    SetComplexVariable('lobcolumn', LOB);
    Execute;
    // After the insert, use the LOB Locator to write the data
    LOB.Write(Buffer, 100);
    LOB.Free;
  end;
end;
You must first insert an empty LOB Locator into the record. To do so, you can use the SQL function empty_blob() in an insert statement. On the server, the LOB Locator will be initialized. The initialized LOB Locator can then be returned to the client in a variable by using the new Oracle8 returning clause. After this, you can start writing data to the LOB column. Note that you must use SetComplexVariable to set a LOB variable.

------------------
Marco Kalter
Allround Automations
 
Back
Top