Page 1 of 1
c++ builder, invalid pointer operation
Posted: Thu 20 Jan 2011 16:52
by Francesco
Hello,
I download the Devart trial dbxepoda.dll. I use c++builder 6 on windows vista, Oracle11g. The scenario:
pl/sql procedure
Code: Select all
create or replace procedure fakeprocedure1(f1 IN NUMERIC, f2 IN NUMERIC) is
begin
insert into faketable (a, b) values (f1, f2);
end fakeprocedure1;
code
Code: Select all
SQLStoredProc1->ParamByName("f1")->AsFMTBCD=StrToBcd(Edit1->Text);
SQLStoredProc1->ParamByName("f2")->AsFMTBCD=StrToBcd(Edit2->Text);
SQLStoredProc1->ExecProc();
everithing is working fine. But here comes problems.
pl/sql procedure
Code: Select all
create or replace procedure fakeprocedure2(f1 IN NUMERIC, f2 IN NUMERIC, f3 OUT NUMERIC) is
begin
insert into faketable (a, b) values (f1, f2);
execute immediate 'select count(*) from faketable' into f3;
end fakeprocedure2;
code
Code: Select all
SQLStoredProc2->ParamByName("f1")->AsFMTBCD=StrToBcd(Edit1->Text); SQLStoredProc2->ParamByName("f2")->AsFMTBCD=StrToBcd(Edit2->Text);
SQLStoredProc2->ExecProc();
ShowMessage(BcdToStr(SQLStoredProc2->ParamByName("f3")->AsFMTBCD));
when "SQLStoredProc2->ExecProc()" is executed an exception occur: EInvalidPointer "Invalid pointer operation". I can't see what's wrong. Thanks in advance.
Francesco
Posted: Fri 21 Jan 2011 08:02
by AlexP
Hello,
I could not reproduce the problem.
Please specify the the exact version of dbExpress driver for Oracle.
I have tested your sample on the 4.70.0.23 version of dbExpress driver for Oracle and all worked fine.
Posted: Fri 21 Jan 2011 08:59
by Francesco
Hello,
thanks for the reply. dbexpoda.dll version is 4.70.0.23 (I downloaded it a couple of days ago). To install the driver I copied the .dll into "C:\Program Files\Borland\CBuilder6\Bin"
and modified, at desing time, TSQLConnection properties as follow:
Code: Select all
GetDriverFunc = "GetSQLDriverORA";
LibraryName = "dbexpoda.dll";
nothing more. Did I miss something during deployment phase? Thanks in advance.
Francesco
Posted: Fri 21 Jan 2011 09:51
by AlexP
Hello,
Please try to execute the following code:
Code: Select all
TSQLConnection *SQLConnection = new TSQLConnection(NULL);
TSQLStoredProc *SQLStoredProc = new TSQLStoredProc(NULL);
SQLConnection->ConnectionName = "Devart Oracle";
SQLConnection->DriverName = "DevartOracle";
SQLConnection->GetDriverFunc = "getSQLDriverORA";
SQLConnection->LibraryName = "dbexpoda.dll";
SQLConnection->VendorLib = "OCI.DLL";
SQLConnection->Params->Values["User_Name"] = "user_name";
SQLConnection->Params->Values["Password"] = "scott";
SQLConnection->Params->Values["DataBase"] = "DATABASE";
SQLConnection->Connected = true;
SQLStoredProc->SQLConnection = SQLConnection;
SQLStoredProc->StoredProcName = "fakeprocedure2";
SQLStoredProc->Prepared = true;
SQLStoredProc->ParamByName("f1")->AsFMTBCD = StrToBcd("1");
SQLStoredProc->ParamByName("f2")->AsFMTBCD =StrToBcd("2");
SQLStoredProc->ExecProc();
ShowMessage(BcdToStr(SQLStoredProc->ParamByName("f3")->AsFMTBCD));
if the problem doesn't arise, please modify the code to reproduce the problem, and send it me.
Posted: Fri 21 Jan 2011 11:47
by Francesco
Hello,
I made some test. Here are the steps I made.
I drop a TSQLStoredProc in the form. Set params and procedure name but not the connection. Run the code:
Code: Select all
SQLStoredProc3->SQLConnection = SQLConnection2;
// SQLStoredProc3->StoredProcName = "fakeprocedure2";
SQLStoredProc3->ParamByName("f1")->AsFMTBCD = StrToBcd(Edit1->Text);
SQLStoredProc3->ParamByName("f2")->AsFMTBCD =StrToBcd(Edit2->Text);
SQLStoredProc3->ExecProc();
ShowMessage(BcdToStr(SQLStoredProc3->ParamByName("f3")->AsFMTBCD));
I got EInvalidPointer exception. Now Drop a TSQLStoredProc in the form. Set params but not the procedure name nor connection. Run the code:
Code: Select all
SQLStoredProc3->SQLConnection = SQLConnection2;
SQLStoredProc3->StoredProcName = "fakeprocedure2";
SQLStoredProc3->ParamByName("f1")->AsFMTBCD = StrToBcd(Edit1->Text);
SQLStoredProc3->ParamByName("f2")->AsFMTBCD =StrToBcd(Edit2->Text);
SQLStoredProc3->ExecProc();
ShowMessage(BcdToStr(SQLStoredProc3->ParamByName("f3")->AsFMTBCD));
The code works fine. The difference is that in the second test I did not set the StoredProcName property by visual component but I set it by code. Weird, isn't it. Can you reproduce this? Maybe I made some mistake I can't figure out. Thanks.
Francesco
Posted: Fri 21 Jan 2011 13:02
by AlexP
Hello,
No, I could not reproduce the problem.
In both cases all works correctly.
Please create a complete small sample to reproduce the problem and send it to alexp*devart*com.