I 'm using ORACLE with UniDAC and I ran into a not expected behaviour.
here is the demo ORACLE procedure:
Code: Select all
create or replace procedure demo_proc
(
o_error_msg out varchar2
)
as
begin
o_error_msg := null;
end;
/
declare
v_error_msg varchar2(10 char);
begin
demo_proc(v_error_msg);
dbms_output.put_line(coalesce(v_error_msg, 'null'));
end;
/
[output]
null
Code: Select all
object spDemo: TUniStoredProc
StoredProcName = 'DEMO_PROC'
SQL.Strings = (
'begin'
' DEMO_PROC(:O_ERROR_MSG);'
'end;')
Connection = conMain
Transaction = trMain
Left = 205
Top = 80
ParamData = <
item
DataType = ftString
Name = 'O_ERROR_MSG'
end>
CommandStoredProcName = 'DEMO_PROC'
end
Code: Select all
spDemo.Execute;
if spDemo.ParamByName('O_ERROR_MSG').IsNull then
ShowMessage('O_ERROR_MSG is null')
else
ShowMessage('O_ERROR_MSG is empty string');
I changed the TUniStoredProc.Options.SetEmptyStrToNull to True, no luck.
When I changed the param's DataType to ftVariant, it suddenly started to work properly, but this is not an acceptable solution.
My problem is when you use ORACLE the empty strings should behave as null values, especially when I explict give an out parameter NULL value I except to retrieve that value on the Delphi side.
When I did the test with a NUMBER out type, it behaved as it should be, the IsNull became True, this is how it supposed to work I guess.