{ $Id: PDOInterfaces.pas 23 2007-01-19 22:06:28Z jmarino $

############################################################################################

	Pascal Data Objects Library
	Copyright © 2006 John Marino, http://www.synsport.com
	Project site: http://pdo.sourceforge.net

	Note: This file contains code fragments from Zeoslib
	Copyright © 1999-2004 Sergey Seroukhov

############################################################################################

	This library is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public
	License as published by the Free Software Foundation; either
	version 2.1 of the License, or (at your option) any later version.

	This library is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
	Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

############################################################################################}

unit PDOInterfaces;

interface

{$I directives.inc}

uses
  Classes, SysUtils, PDOClasses, PDOLogging, PDOMessages, PDOStatement;

// Exceptions
type

  {** Abstract SQL exception. }
  EZSQLThrowable = class(Exception)
  private
    FErrorCode: Integer;
  public
    constructor Create(const Msg: string);
    constructor CreateWithCode(const ErrorCode: Integer; const Msg: string);

    property ErrorCode: Integer read FErrorCode;
  end;

  {** Generic SQL exception. }
  EZSQLException = class(EZSQLThrowable);

  {** Generic SQL warning. }
  EZSQLWarning = class(EZSQLThrowable);

// Data types
type
  {** Defines supported SQL types. }
  TZSQLType = (stUnknown, stBoolean, stByte, stShort, stInteger, stLong, stFloat,
    stDouble, stBigDecimal, stString, stUnicodeString, stBytes, stDate, stTime,
    stTimestamp, stAsciiStream, stUnicodeStream, stBinaryStream);

  {** Defines a transaction isolation level. }
  TZTransactIsolationLevel = (tiNone, tiReadUncommitted, tiReadCommitted,
    tiRepeatableRead, tiSerializable);

  PCONNECTION = pointer;

type

  {** Database Connection interface. }
  IZConnection = interface(IInterface)
    ['{8EEBBD1A-56D1-4EC0-B3BD-42B60591457F}']

    procedure SetAutoCommit(Value: Boolean);
    function GetAutoCommit: Boolean;

    procedure Commit;
    procedure Rollback;

    procedure Open;
    procedure Close;
    function IsClosed: Boolean;

    procedure SetTransactionIsolation(Value: TZTransactIsolationLevel);
    function GetTransactionIsolation: TZTransactIsolationLevel;

    function execute_without_result (SQL: AnsiString): Int64;
    function GetConnectionHandle: PCONNECTION;
    function InitializeStatement: IPDOStatement;

    function GetSilentMode: Byte;
    function GetCaseMode: Byte;
    function GetOracleNull: Byte;
    function GetBufferQuery: Boolean;
    function GetCompression: Boolean;
    function GetMaximumBLOBSize: Int64;
    function GetMultipleQuery: Boolean;

    procedure SetSilentMode (mode: Byte);
    procedure SetCaseMode (mode: Byte);
    procedure SetOracleNull (mode: Byte);
    procedure SetBufferQuery (mode: Boolean);
    procedure SetCompression (mode: Boolean);
    procedure SetMaximumBLOBSize (BLOBSize: Int64);
    procedure SetMultipleQuery (mode: Boolean);

    function GetSQLDialect: TSQLDialect;
    function GetLastInsertID: Int64;
    function GetSQLState: AnsiString;
    function GetLastErrorCode: Integer;
    function GetLastErrorMessage: AnsiString;
    function GetServerVersion: AnsiString;
    function GetClientVersion: AnsiString;
    function GetServerInfo: AnsiString;
    function GetClientInfo: AnsiString;
    function GetDescription: AnsiString;

    property LastInsertID:  Int64 READ GetLastInsertID;
    property LastErrorCode: Integer READ GetLastErrorCode;
    property SQLState:      AnsiString READ GetSQLState;
    property LastErrorMsg:  AnsiString READ GetLastErrorMessage;
    property ServerVersion: AnsiString READ GetServerVersion;
    property ClientVersion: AnsiString READ GetClientVersion;
    property ServerInfo:    AnsiString READ GetServerInfo;
    property ClientInfo:    AnsiString READ GetClientInfo;
    property SilentMode:    Byte READ GetSilentMode WRITE SetSilentMode;
    property CaseMode:      Byte READ GetCaseMode WRITE SetCaseMode;
    property OracleNulls:   Byte READ GetOracleNull WRITE SetOracleNull;
    property BufferQuery:   Boolean READ GetBufferQuery WRITE SetBufferQuery;
    property Compression:   Boolean READ GetCompression WRITE SetCompression;
    property MaxBLOBSize:   Int64 READ GetMaximumBLOBSize WRITE SetMaximumBLOBSize;
    property MultipleQuery: Boolean READ GetMultipleQuery WRITE SetMultipleQuery;
  end;

    IPDOProtocol = interface (IInterface)
  ['{F06DEB80-2063-48B9-87D1-B52C5F8C6C3F}']

    function GetProtocol: AnsiString;
    function GetDescription: AnsiString;
    procedure initialize;

    function GetSilentMode: Byte;
    function GetCaseMode: Byte;
    function GetOracleNull: Byte;
    function GetBufferQuery: Boolean;
    function GetMaximumBLOBSize: Int64;

    procedure SetSilentMode (mode: Byte);
    procedure SetCaseMode (mode: Byte);
    procedure SetOracleNull (mode: Byte);
    procedure setBufferQuery (mode: Boolean);
    procedure setMaximumBLOBSize (BLOBSize: Int64);

    function GetSQLDialect: TSQLDialect;
    function getLastInsertID (Handle: PCONNECTION): Int64;
    function getSQLState (Handle: PCONNECTION): AnsiString;
    function getLastErrorCode (Handle: PCONNECTION): Integer;
    function getLastErrorMessage (Handle: PCONNECTION): AnsiString;
    function GetServerVersion (Handle: PCONNECTION): AnsiString;
    function GetClientVersion: AnsiString;
    function GetServerInfo (Handle: PCONNECTION): AnsiString;
    function GetClientInfo: AnsiString;
    function GetLastPreparedErrorCode(Handle: PCONNECTION): Integer;
    function GetLastPreparedError(Handle: PCONNECTION): AnsiString;
    procedure preconnect(Info: TStringList; listenerHandle: TZAbstractLoggingListener);
  end;





implementation


{ EZSQLThrowable }

{**
  Creates an exception with message string.
  @param Msg a error description.
}
constructor EZSQLThrowable.Create(const Msg: string);
begin
  inherited Create(Msg);
  FErrorCode := -1;
end;

{**
  Creates an exception with message string.
  @param Msg a error description.
  @param ErrorCode a native server error code.
}
constructor EZSQLThrowable.CreateWithCode(const ErrorCode: Integer;
  const Msg: string);
begin
  inherited Create(Msg);
  FErrorCode := ErrorCode;
end;


end.


