Oracle clob insert fails

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

Oracle clob insert fails

Post by albourgz » Wed 03 Aug 2016 14:12

Hi,
using unidac 6.3.13 with c++ builder XE10 pro. ODAC 9.7.25 is also installed.

New VCL project, drop a TUniConnection component, connect it to oracle (12.1.0.2 SE in this case), set custom properties:
defaultSortType=stCaseInsensitive

SpecificOptions: for oracle:
DateFormat=YYYY-MM-DD
DateLanguage=FRENCH
Direct=True
EnableLargeInt=true
UseUnicode=true.

On the form, drop:
a TOracleUniProvider
a TImage
a TMemo
a TUniQuery named InsClob, sql text is:

Code: Select all

insert into testclob values (:id, :clobb)
a TUniQuery named InsBlob, sql text is:

Code: Select all

insert into testblob values (:id, :blobb)
Run the following sql statement to create tables:

Code: Select all

create table testclob(id number(5), texte clob, primary key(id)) tablespace USERS;
create table testblob(id number(5), pic blob, primary key(id)) tablespace USERS;
Drop a TButton on the form, paste the onClick event to rows to table (change file paths to existing text and
binary files):

Code: Select all

    AnsiString sBinFile[5], sTextFile[5];

    sTextFile[0]="c:\\tstfiles\\f1.xml";
    sTextFile[1]="c:\\tstfiles\\f2.xml";
    sTextFile[2]="c:\\tstfiles\\f3.xml";
    sTextFile[3]="c:\\tstfiles\\f4.xml";
    sTextFile[4]="c:\\tstfiles\\f5.cpp";
    sBinFile[0]="c:\\tstfiles\\f1.bmp";
    sBinFile[1]="c:\\tstfiles\\f2.bmp";
    sBinFile[2]="c:\\tstfiles\\f3.bmp";
    sBinFile[3]="c:\\tstfiles\\f4.bmp";
    sBinFile[4]="c:\\tstfiles\\f5.bmp";

    int i;
    UniConnection1->StartTransaction();
    InsClob->Prepare();
    InsBlob->Prepare();
    for (i=0; i<5; i++) {
        Memo1->Lines->Clear();
        Memo1->Lines->LoadFromFile(sTextFile[i]);
        InsClob->Params->Items[0]->AsInteger=i+1;
        InsClob->Params->Items[1]->AsWideString=Memo1->Lines->Text;
        InsClob->Execute();
        }
    for (i=0; i<5; i++) {
        Image1->Picture->LoadFromFile(sBinFile[i]);
        InsBlob->Params->Items[0]->AsInteger=i+1;
        InsBlob->Params->Items[1]->AsBlobRef->LoadFromFile(sBinFile[i]);
        InsBlob->Execute();
        }
    UniConnection1->Commit();
Then debug. At run-time, first run of InsClob->Execute(); works, second iteration fails (although file is correctly loaded in memo) with "project74.exe raised exception class EInternalError with message '' in oraprovider.bpl".

Why why why?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Oracle clob insert fails

Post by AlexP » Tue 16 Aug 2016 06:42

Hello,

The code you have provided works without errors. Please send a complete sample to support*devart*com, including XML file that causes the error

albourgz
Posts: 160
Joined: Wed 06 May 2009 12:17
Location: belgium

Re: Oracle clob insert fails

Post by albourgz » Tue 16 Aug 2016 07:06

Sorry, problem fixed meanwhile.
->AsWideString didn't work, I replaced it with ->AsMemo and then it worked.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Oracle clob insert fails

Post by AlexP » Tue 16 Aug 2016 10:06

Glad to see that you have found the solution. If you have any other questions, feel free to contact us

Post Reply