Creo que la mejor forma de independizar del motor es usando interfaces:
Código Delphi
[-]
unit SQLFunctions;
interface
uses
Data.DB;
type
ISQLFunctions = interface
['{CD84579F-2EE3-4842-BCF3-F8B5A2B7C50B}']
function NullFx(const ParamName, FieldName: string): string;
end;
TExtendedSQLConnection = class abstract(TInterfacedObject, ISQLFunctions)
protected
FConnection: TCustomConnection;
function NullFx(const ParamName, FieldName: string): string; virtual; abstract;
public
constructor Create(const AConnection: TCustomConnection); virtual;
end;
implementation
uses
System.SysUtils;
constructor TExtendedSQLConnection.Create(const AConnection: TCustomConnection);
begin
if not Assigned(AConnection) then
raise Exception.Create('TExtendedSQLConnection.Create :: AConnection is not Assigned');
inherited Create;
FConnection := AConnection;
end;
end.
Código Delphi
[-]
unit MySQLFunctions;
interface
uses
SQLFunctions;
type
TMySQLExtendedConnection = class(TExtendedSQLConnection)
protected
function NullFx(const ParamName, FieldName: string): string; override;
end;
implementation
uses
System.SysUtils;
function TMySQLExtendedConnection.NullFx(const ParamName, FieldName: string): string;
begin
Result := Format('IfNull(:%s, %s)', [ParamName, FieldName]);
end;
end.
Código Delphi
[-]
unit MSSQLFunctions;
interface
uses
SQLFunctions;
type
TMSSQLExtendedConnection = class(TExtendedSQLConnection)
protected
function NullFx(const ParamName, FieldName: string): string; override;
end;
implementation
uses
System.SysUtils;
function TMSSQLExtendedConnection.NullFx(const ParamName, FieldName: string): string;
begin
Result := Format('IsNull(:%s, %s)', [ParamName, FieldName]);
end;
end.