Error while reading a blob field
Error while reading a blob field
I have this table in postgresql :
CREATE TABLE sif_pictogrami
(
id serial NOT NULL,
picture oid,
naziv character varying(100)
)
WITH (OIDS=FALSE);
ALTER TABLE sif_pictogrami OWNER TO postgres;
I use this UniQuery "select * from sif_pictogrami" to open a table and give me error active trasaction is required for operation for large objects. to insert a picture i use
'INSERT INTO sif_pictogrami (picture) VALUES(lo_import(' + '''' + FileName + '''' + '));'
this query and i have no problem. I also try the example from C:\Program Files\Devart\UniDac for Delphi 7\Demos\UniDacDemo\Pictures but that example does not store the picture in the data base only load from the file and when i try to POST give me the same error.
Any help how can i store, view data in oid field from Delphi 7.
CREATE TABLE sif_pictogrami
(
id serial NOT NULL,
picture oid,
naziv character varying(100)
)
WITH (OIDS=FALSE);
ALTER TABLE sif_pictogrami OWNER TO postgres;
I use this UniQuery "select * from sif_pictogrami" to open a table and give me error active trasaction is required for operation for large objects. to insert a picture i use
'INSERT INTO sif_pictogrami (picture) VALUES(lo_import(' + '''' + FileName + '''' + '));'
this query and i have no problem. I also try the example from C:\Program Files\Devart\UniDac for Delphi 7\Demos\UniDacDemo\Pictures but that example does not store the picture in the data base only load from the file and when i try to POST give me the same error.
Any help how can i store, view data in oid field from Delphi 7.
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
The large object handle is valid only in the context of current transaction. When you commit/rollback transaction, all opened objects are closed. PgDAC tries to close the object on freeing of TPgSqlLargeObject. If the handle is already closed, it raises an exception. That's why you get the mentioned exception. But this exception is internally catched and is visible in the debug mode only.
First time you need transaction when you open the table to read large objects:
When you add a row, you also need to start transaction:
Code: Select all
PgConnection.StartTransaction;
PgTable.Open;
PgConnection.Rollback;
Code: Select all
PgConnection.StartTransaction;
PgTable.Insert;
PgRow := PgTable.GetPgRow('picture');
PgRow.LoadFromFile(FileName);
PgTable.Post;
PgRow.CloseObject; // make sure object is closed before the transaction is commited
PgConnection.Commit;