Page 1 of 1

11.3.2 variant and string problem

Posted: Wed 28 Oct 2020 18:51
by valentl
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;

Re: 11.3.2 variant and string problem

Posted: Thu 29 Oct 2020 21:05
by MaximG
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',[]));
   ...

Re: 11.3.2 variant and string problem

Posted: Fri 30 Oct 2020 07:01
by valentl
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?

:(

Re: 11.3.2 variant and string problem

Posted: Fri 30 Oct 2020 14:19
by MaximG
Yes, the behavior will remain the same for future versions of ODAC. It makes sense to revise the ExecProc function calls in your code.