Page 1 of 1

TMyStoredProc, set null strings to empty string?

Posted: Mon 17 Mar 2014 12:12
by docH
I have ver 8.2.6 of TmyStoredProc.
I have a stored procedure in the database that returns two Varchars, one or both of which might be null.

The code below gives an exception in Delphi if the the parameter is null

Code: Select all

...
 MyStoredproc1.Execute;
 MyStringVar:= MyStoredproc1.ParamByName('MyParamName').AsString;
...
end;
Is there an easy way in TMyStoredProc to automatically convert null varchars to an empty string or do I have to alter my SQL with IFNULL(FieldName,"") and do it all in the procedure before returning any values?

Re: TMyStoredProc, set null strings to empty string?

Posted: Thu 20 Mar 2014 14:20
by AlexP
Hello,

Please specify when the exception is raised (and provide the error message text): on method execution or when calling the parameter. In addition, if you use SELECT in your procedure and want to call fields of the generated ResultSet, then you should use FieldByName instead of ParamByName.
If the parameter value is NULL, then, when calling the AsString property, the Null value will be mapped to an empty string.