Page 1 of 1

OraLob->LoadFromFile error - bcb 2010 - odac 6.90.0.57

Posted: Wed 08 Jun 2011 15:28
by albourgz
Hi, I have the following table (id is a pk):

Code: Select all

SQL> desc CEC.customerItemBook
 Nom                                       NULL ?   Type
 ----------------------------------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER(10)
 REF                                                VARCHAR2(50)
 VERSION                                   NOT NULL NUMBER(2)
 EXT                                                VARCHAR2(10)
 FILECONTENT                                        BLOB
SQL> insert into CEC.customerItemBook values (3,'ABC',1, null, null);
1 ligne créée.
SQL> commit;
Validation effectuée.
SQL>
To fill in the lob, I use a TOraQuery *q with this statement:

Code: Select all

UPDATE CEC.customerItemBook SET ext=:1, filecontent=:2 WHERE ID=:3

Code: Select all

    q->Params->Items[0]->AsString=L"pdf";
    q->Params->Items[1]->AsOraBlob->LoadFromFile("X:\toto.pdf");
    q->Params->Items[2]->AsInteger=3;
    q->ExecSQL();
Problems:
1. If PDF file is opened (even read-only in acrobat reader), I get an exception during the LoadFromFile, that seems to need an exclusive access,
2. IF PDF is closed, I get an ORA-22275. I tried also

Code: Select all

    q->Params->Items[1]->AsBLOBLocator->LoadFromFile("x:\toto.pdf");
and I also get an ora-22275.

Any hint to avoid these 2 problems?

Regards,
Alain

Posted: Thu 09 Jun 2011 07:33
by AlexP
Hello,

1) Thank you for the information, we have reproduced the problem with the error on loading opened files. We will try to fix it in the nearest future.

2) To solve this problem, please use thie following code for loading Blob data:

Code: Select all

OraQuery->SQL->Text = "UPDATE customerItemBook SET ext=:1, filecontent=:2 WHERE ID=:3 ";
 OraQuery->Options->TemporaryLobUpdate = True;
 OraQuery->Params->Items[0]->AsString = L"pdf";;
 OraQuery->Params->Items[1]->ParamType = ptInput;
 OraQuery->Params->Items[1]->DataType = ftOraBlob;
 OraQuery->Params->Items[1]->AsOraBlob->LoadFromFile("D:\ODAC.pdf");
 OraQuery->Params->Items[2]->AsInteger=3;
 OraQuery->ExecSQL();