Page 1 of 1

Postgresql update blob field, how to

Posted: 26.12.2007, 10:28
by sevenmiles
hi, I'm writing code in C++builder6.
tbl_test has

id varchar
user_id varchar
facial_photo bytea

my code is like below

ZQuery1->SQL->Add("select * from tbl_test where id='0001'");
ZQuery1->Open();
if(ZQuery1->RecordCount != 0)
{
ZQuery1->Active = true;
ZQuery1->Edit();
TStream *BlobStream = ZQuery1->CreateBlobStream(
ZQuery1->FieldByName("facial_photo"), bmWrite);
TFileStream *FileStream = new TFileStream("test.jpg");
BlobStream->CopyFrom(FileStream);
ZQuery1->Post();
FileStream->Free();
BlobStream->Free();
}
ZQuery1->Close();

but I can't update this field. while I can update other fields by ZQuery1->SetData method.
What's wrong about my code?? :(

Thank you.

Posted: 28.12.2007, 18:14
by RDNK
try before set data to NULL, and after this load your binary data

Posted: 07.01.2008, 03:11
by sevenmiles
thank you, RDNK.
I'll try it