Page 1 of 1

Problem updating OID field

Posted: Sat 15 May 2010 07:58
by Excessive
I'm trying to store an image to the database which has an OID type.

What I'm trying to do is, store the members' photo with the following code:

Code: Select all

with UniQuery1 do
begin
      SQL.Clear;
      SQL.Add('select * from members where identity_no = ''' + sEdit2.Text + '''');
      Execute;
      Edit;
      TBlobField(Fields[4]).LoadFromFile(ImageFile);
      Post;
end;

but I'm receiving an error saying "Active Transaction is required for working with large objects".

What's the problem here?

Thank you in advance.

Posted: Mon 17 May 2010 13:35
by bork
Hello

PostgreSQL allows to change large objects like OID's only in the transaction. So you should try the following code:

Code: Select all

with UniQuery1 do
begin
  SQL.Clear;
  SQL.Add('select * from members where identity_no = ''' + sEdit2.Text + '''');
  Execute;

  PgConnection1.StartTransaction;
  try 
    Edit;
    TBlobField(Fields[4]).LoadFromFile(ImageFile);
    Post;
    PgConnection1.Commit;
  except
    PgConnection1.Rollback;
  end;
end;