Page 1 of 1
Doug Hurst
Posted: Mon 06 Jun 2005 16:09
by Doug Hurst
"You can retrieve values of LOB fields using TOraQuery component the same way as you do for LONG or LONG RAW fields." is from the ODAC help in Borland C++ 5.0 (plus updates).
In C++ code, are there any examples of retrieving a BLOB to a file using the standard TOraQuery? Say I had a table with two columns, SSN Varchar and RECORD BLOB. In C++, how could I select (*) from this table and write each RECORD BLOB out to a file?
Posted: Wed 08 Jun 2005 06:05
by Alex
Please see our BlobPics and Long demo projects.
BLOB retrieval (Doug Hurst)
Posted: Thu 09 Jun 2005 12:25
by Doug Hurst
I'm trying. Can you tell me why this is not working? It compiles ok, but I get a access violation at runtime.
"Project OracleTest.exe raised exception class EAccessViolation with message 'Access violation at address..... Read address.....: Process stopped. Use..."
AnsiString asReceiptNumber;
try
{
OraQuery1->Close();
OraQuery1->SQL->Clear();
OraQuery1->SQL->Add(" select receipt_number, blob_field");
OraQuery1->SQL->Add(" from tmp_receipt_blob");
OraQuery1->SQL->Add(" where receipt_number = 'LIN9901050011'");
OraQuery1->Prepare();
if (OraQuery1->Prepared == true)
{
OraQuery1->Open();
if (OraQuery1->FindFirst() == true)
{
Memo->Lines->Add(OraQuery1->Fields->Fields[0]->AsString);
new TBlobField(OraQuery1->FieldByName("BLOB_FIELD"))->SaveToFile("junk.jpg");
}
}
}
catch(...)
{
Memo->Lines->Add("SQL failed.");
}
BLOB (Doug Hurst)
Posted: Thu 09 Jun 2005 12:54
by Doug Hurst
Never mind. This did the trick
void __fastcall TForm1::GetBLOBBtnClick(TObject *Sender)
{
AnsiString asReceiptNumber;
try
{
OraQuery1->Close();
OraQuery1->SQL->Clear();
OraQuery1->SQL->Add(" select receipt_number, blob_field");
OraQuery1->SQL->Add(" from tmp_receipt_blob");
OraQuery1->SQL->Add(" where receipt_number = 'LIN9901050011'");
OraQuery1->Prepare();
if (OraQuery1->Prepared == true)
{
OraQuery1->Open();
if (OraQuery1->FindFirst() == true)
{
Memo->Lines->Add(OraQuery1->Fields->Fields[0]->AsString);
OraQuery1->GetLob("BLOB_FIELD")->SaveToFile("junk.jpg");
}
}
}
catch(...)
{
Memo->Lines->Add("SQL failed.");
}
}
//---------------------------------------------------------------------------