Problems with "TPgLargeObjectField"
Problems with "TPgLargeObjectField"
Hi,
i have some trouble with BLOB Fields.
1) Delphi does not know the class TPgLargeObjectField, so each time i open a form delphi says "unkown class". it seems that this fieldtype isn't registered? (RegisterClass)
If i call Registerclass everything works fine.
2) if i set the Blobtype to ftBlob i always get
"Type mismatch for field 'mm_picture', expecting: TBlobField actual: TPgLargeObjectField".
FieldType in Database is oid.
The reason seems to be the BlobType property of the TPgLargeObjectField. It seems that Blobtype is not set correct. If i try to compile i get "unsupported 16 bit resource in file X". If i look into the dfm:
object MainMenumm_picture: TPgLargeObjectField
FieldName = 'mm_picture'
BlobType =
end
if setting the blobtype on ftBlob error 2) is raised.
can anyone give a tip
Using PostgreSQL 8.1
i have some trouble with BLOB Fields.
1) Delphi does not know the class TPgLargeObjectField, so each time i open a form delphi says "unkown class". it seems that this fieldtype isn't registered? (RegisterClass)
If i call Registerclass everything works fine.
2) if i set the Blobtype to ftBlob i always get
"Type mismatch for field 'mm_picture', expecting: TBlobField actual: TPgLargeObjectField".
FieldType in Database is oid.
The reason seems to be the BlobType property of the TPgLargeObjectField. It seems that Blobtype is not set correct. If i try to compile i get "unsupported 16 bit resource in file X". If i look into the dfm:
object MainMenumm_picture: TPgLargeObjectField
FieldName = 'mm_picture'
BlobType =
end
if setting the blobtype on ftBlob error 2) is raised.
can anyone give a tip
Using PostgreSQL 8.1
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
-
- Devart Team
- Posts: 925
- Joined: Thu 17 Nov 2005 10:53
Hi Challanger,
Problem #2
Please Try:
Create a Table with a oid column.
Create a Query in Delphi, Create Fields at DesignTime with the "CerateAllFields" Popup. Now you can see my Problem #2:
It is the "TPgLargeObjectField"s property BlobType wich makes trouble.
I have a new small issue for you:
SELECT a+b AS calc_c FROM x;
Now PgDac maps c as a normal (Data)Field and if you Update this field you get an error because the update statement looks like "UPDATE x SET calc_c=..."
thats clear. and done already. but currently all fields are of type oid, not bytea in database. Also i have some trouble with the example in the documentation too, but i will research it more. currently i'm unable to get my oid data.Please note that all operations with Large Object data type should be performed in transaction. Please take a look at BYTEA data type. You can also refer to the PgDAC help, "Working with Large Objects" article.
Problem #2
Please Try:
Create a Table with a oid column.
Create a Query in Delphi, Create Fields at DesignTime with the "CerateAllFields" Popup. Now you can see my Problem #2:
It is the "TPgLargeObjectField"s property BlobType wich makes trouble.
I have a new small issue for you:
SELECT a+b AS calc_c FROM x;
Now PgDac maps c as a normal (Data)Field and if you Update this field you get an error because the update statement looks like "UPDATE x SET calc_c=..."
We have fixed the problems with registering field classes and with the BlobType property. The fixes will be included in the next PgDAC build.
By default PgDAC sets the ReadOnly flag for fields that are based on expressions. So you cannot edit this field. If you change the SetFieldsReadOnly option of TPgQuery to False, you can edit such field, but it is not included in UPDATE statement anyway.
We cannot reproduce the problem with editing the field. Please send to pgdac*devart*com a small sample that demonstrates the problem, including the script for creating database objects.
By default PgDAC sets the ReadOnly flag for fields that are based on expressions. So you cannot edit this field. If you change the SetFieldsReadOnly option of TPgQuery to False, you can edit such field, but it is not included in UPDATE statement anyway.
We cannot reproduce the problem with editing the field. Please send to pgdac*devart*com a small sample that demonstrates the problem, including the script for creating database objects.
yes, your right, so problem seems to be more complicated, i send a demo.By default PgDAC sets the ReadOnly flag for fields that are based on expressions. So you cannot edit this field. If you change the SetFieldsReadOnly option of TPgQuery to False, you can edit such field, but it is not included in UPDATE statement anyway.
We cannot reproduce the problem with editing the field. Please send to pgdac*devart*com a small sample that demonstrates the problem, including the script for creating database objects.
BLOB OID
the Blob Problem is very simple:
ReadBlob and WriteBlob is required. thats not clear in the documentation.
ReadBlob
WriteBlob
ReadBlob and WriteBlob is required. thats not clear in the documentation.
ReadBlob
Code: Select all
Assert(OpenDialog1.Execute());
PgConnection1.StartTransaction;
LargeObject := TPgLargeObject.Create(PgConnection1);
LargeObject.OID:=PGQuery1.FieldByName('picture').AsInteger;
LargeObject.OpenObject;
LargeObject.ReadBlob;
LargeObject.SaveToFile(OpenDialog1.FileName);
LargeObject.CloseObject;
Code: Select all
Assert(OpenDialog1.Execute());
LargeObject := TPgLargeObject.Create(PgConnection1);
PgConnection1.StartTransaction;
PGQuery1.Insert;
LargeObject.CreateObject;
LargeObject.LoadFromFile(OpenDialog1.FileName);
LargeObject.WriteBlob;
LargeObject.CloseObject;
PGQuery1.FieldByName('picture').AsInteger:=LargeObject.OID;
PgQuery1.Post;
PgConnection1.Commit;