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;
11.3.2 variant and string problem
Re: 11.3.2 variant and string problem
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:
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
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?
:(
Do we need to revise all of our ExecProc function calls?
:(
Re: 11.3.2 variant and string problem
Yes, the behavior will remain the same for future versions of ODAC. It makes sense to revise the ExecProc function calls in your code.