Ejemplo de uso:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
begin
ADOQuery1.Close;
if Edit1.Text = EmptyStr then
ADOQuery1.Parameters.ParamByName('Param').Value := NULL
else
ADOQuery1.Parameters.ParamByName('Param').Value := Edit1.Text;
ADOQuery1.Open;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FSQLFunctions := TMSSQLExtendedConnection.Create(ADOConnection1);
ADOQuery1.SQL.Text := 'SELECT * FROM Productos WHERE Id = ' + FSQLFunctions.NullFx('Param', 'Id');
ADOQuery1.Prepared := True;
end;
Edito:
Si las funciones para comprobar si es Null o no comprometen la eficiencia, la
unica manera es usando dos componentes Query.