Ver Mensaje Individual
  #12  
Antiguo 27-09-2015
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Reputación: 15
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
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;

{ TExtendedSQLConnection }

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;

{ TMySQLExtendedConnection }

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;

{ TMSSQLExtendedConnection }

function TMSSQLExtendedConnection.NullFx(const ParamName, FieldName: string): string;
begin
  Result := Format('IsNull(:%s, %s)', [ParamName, FieldName]);
end;

end.

Última edición por AgustinOrtu fecha: 27-09-2015 a las 21:57:18.
Responder Con Cita