Doug Hurst

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Doug Hurst
Posts: 5
Joined: Thu 19 May 2005 19:04
Location: Fairfax, VA 22031

Doug Hurst

Post by Doug Hurst » Mon 06 Jun 2005 16:09

"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?

Alex
Posts: 655
Joined: Mon 08 Nov 2004 08:39

Post by Alex » Wed 08 Jun 2005 06:05

Please see our BlobPics and Long demo projects.

Doug Hurst
Posts: 5
Joined: Thu 19 May 2005 19:04
Location: Fairfax, VA 22031

BLOB retrieval (Doug Hurst)

Post by Doug Hurst » Thu 09 Jun 2005 12:25

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.");
}

Doug Hurst
Posts: 5
Joined: Thu 19 May 2005 19:04
Location: Fairfax, VA 22031

BLOB (Doug Hurst)

Post by Doug Hurst » Thu 09 Jun 2005 12:54

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.");
}
}
//---------------------------------------------------------------------------

Post Reply