we updated ODAC VCL 11.1.3 to 11.3.2 and got a problem assigning a result param of a function with the Value property to a string.
When the result is NULL it throws an EVariantTypeCastError "Could not convert variant of type (Null) into type (OleStr)".
If we use the AsString property everything is fine. We know that using AsString is always recommended, but we have old legacy code in many older projects, so we'd prefer not to change that, if possible.
Code: Select all
str := OraStoredProc1.ParamByName('RESULT').Value; // the RESULT is NULL
ODAC VCL 11.3.2 throws the EVariantTypeCastError
A small example:
ORACLE Code
Code: Select all
CREATE OR REPLACE FUNCTION FncTestODAC(p NUMBER) RETURN VARCHAR2 IS
BEGIN
IF p = 0 THEN
RETURN 'TEST';
ELSIF p = 1 THEN
RETURN NULL;
END IF;
END;
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
var
str : string;
begin
OraStoredProc1.ParamByName('P').AsInteger := 1;
OraStoredProc1.ExecSQL();
str := OraStoredProc1.ParamByName('RESULT').AsString; // Works str = ''
str := OraStoredProc1.ParamByName('RESULT').Value; // Throw EVariantTypeCastError "Could not convert variant of type (Null) into type (OleStr)"
OraStoredProc1.ParamByName('P').AsInteger := 0;
OraStoredProc1.ExecSQL();
str := OraStoredProc1.ParamByName('RESULT').AsString; // Works str = 'TEST'
str := OraStoredProc1.ParamByName('RESULT').Value; // Works str = 'TEST'
end;
Can you help?
Thanks
Ingo