Postgresql update blob field, how to

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
sevenmiles
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 26.12.2007, 10:09

Postgresql update blob field, how to

Post 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.
RDNK
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 22.12.2007, 18:59
Location: Ukraine

Post by RDNK »

try before set data to NULL, and after this load your binary data
sevenmiles
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 26.12.2007, 10:09

Post by sevenmiles »

thank you, RDNK.
I'll try it
Post Reply