Problem updating OID field

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Excessive
Posts: 9
Joined: Tue 13 Oct 2009 06:44

Problem updating OID field

Post by Excessive » Sat 15 May 2010 07:58

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.

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Mon 17 May 2010 13:35

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; 

Post Reply