11.3.2 variant and string problem

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
valentl
Posts: 16
Joined: Wed 22 May 2013 06:15

11.3.2 variant and string problem

Post by valentl » Wed 28 Oct 2020 18:51

Hello,
Today I tried the Odac 11.3.2 components, and I ran into a problem.
Previously, we used Odac 11.2.5
With Odac 11.2.5 (and every version before), when a stored function returned a null value, I was able to read it's result directly into a string variable without problems.
Numeric results did not worked before, I know, but I had no problem with strings.

Now, when I execute this procedure, I get variant error.
This is the oracle function (of course, the empty string is a null value in oracle)
create or replace function doNothing return varchar2 is
begin
return '';
end;
/

When I call this function from Delphi, I get this error message.

var
s:string;
begin
s:=DefSession.ExecProcEx('donothing',[]);
end;

---------------------------
Debugger Exception Notification
---------------------------
Project odatesz.exe raised exception class EVariantTypeCastError with message 'Could not convert variant of type (Null) into type (OleStr)'.


Of course, if I read the parameter value, it works, but please, we used the Execproc method thousands of times with this call, wihtout problems.

var
s:string;
begin
DefSession.ExecProcEx('donothing',[]);
s:=DefSession.ParamByName('result').asString;
end;

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: 11.3.2 variant and string problem

Post by MaximG » Thu 29 Oct 2020 21:05

Previous versions of our components had an error: NULL values returned by the server were treated as Output parameters, which were then converted to an empty string.
The issue has been fixed in the latest version of ODAC. To get the necessary value, you can do the following:

Code: Select all

   ...
   s := VarToStr(OraSession.ExecProcEx('donothing',[]));
   ...

valentl
Posts: 16
Joined: Wed 22 May 2013 06:15

Re: 11.3.2 variant and string problem

Post by valentl » Fri 30 Oct 2020 07:01

Does it mean, that the behavior of the 11.3.2 version will not be changed, and it will remain the same?
Do we need to revise all of our ExecProc function calls?

:(

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: 11.3.2 variant and string problem

Post by MaximG » Fri 30 Oct 2020 14:19

Yes, the behavior will remain the same for future versions of ODAC. It makes sense to revise the ExecProc function calls in your code.

Post Reply