mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 09:06:02 +02:00
fcl-db: sqldb: formatting
git-svn-id: trunk@25166 -
This commit is contained in:
parent
bc7fd7afa8
commit
59b2c38530
@ -115,40 +115,42 @@ type
|
|||||||
FConnOptions : TConnOptions;
|
FConnOptions : TConnOptions;
|
||||||
FSQLFormatSettings : TFormatSettings;
|
FSQLFormatSettings : TFormatSettings;
|
||||||
procedure GetDBInfo(const ASchemaType : TSchemaType; const ASchemaObjectName, AReturnField : string; AList: TStrings);
|
procedure GetDBInfo(const ASchemaType : TSchemaType; const ASchemaObjectName, AReturnField : string; AList: TStrings);
|
||||||
procedure SetTransaction(Value : TSQLTransaction);virtual;
|
procedure SetTransaction(Value : TSQLTransaction); virtual;
|
||||||
function StrToStatementType(s : string) : TStatementType; virtual;
|
|
||||||
procedure DoInternalConnect; override;
|
procedure DoInternalConnect; override;
|
||||||
procedure DoInternalDisconnect; override;
|
procedure DoInternalDisconnect; override;
|
||||||
function GetAsSQLText(Field : TField) : string; overload; virtual;
|
function GetAsSQLText(Field : TField) : string; overload; virtual;
|
||||||
function GetAsSQLText(Param : TParam) : string; overload; virtual;
|
function GetAsSQLText(Param : TParam) : string; overload; virtual;
|
||||||
function GetHandle : pointer; virtual; virtual;
|
function GetHandle : pointer; virtual;
|
||||||
Function LogEvent(EventType : TDBEventType) : Boolean;
|
Function LogEvent(EventType : TDBEventType) : Boolean;
|
||||||
Procedure Log(EventType : TDBEventType; Const Msg : String); virtual;
|
Procedure Log(EventType : TDBEventType; Const Msg : String); virtual;
|
||||||
Function AllocateCursorHandle : TSQLCursor; virtual; abstract;
|
|
||||||
Procedure DeAllocateCursorHandle(var cursor : TSQLCursor); virtual; abstract;
|
|
||||||
Function AllocateTransactionHandle : TSQLHandle; virtual; abstract;
|
|
||||||
Procedure RegisterStatement(S : TCustomSQLStatement);
|
Procedure RegisterStatement(S : TCustomSQLStatement);
|
||||||
Procedure UnRegisterStatement(S : TCustomSQLStatement);
|
Procedure UnRegisterStatement(S : TCustomSQLStatement);
|
||||||
|
|
||||||
|
Function AllocateCursorHandle : TSQLCursor; virtual; abstract;
|
||||||
|
Procedure DeAllocateCursorHandle(var cursor : TSQLCursor); virtual; abstract;
|
||||||
|
function StrToStatementType(s : string) : TStatementType; virtual;
|
||||||
|
function GetStatementInfo(const ASQL: string; Full: Boolean; ASchema : TSchemaType): TSQLStatementInfo; virtual;
|
||||||
procedure PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLTransaction;buf : string; AParams : TParams); virtual; abstract;
|
procedure PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLTransaction;buf : string; AParams : TParams); virtual; abstract;
|
||||||
|
procedure UnPrepareStatement(cursor : TSQLCursor); virtual; abstract;
|
||||||
procedure Execute(cursor: TSQLCursor;atransaction:tSQLtransaction; AParams : TParams); virtual; abstract;
|
procedure Execute(cursor: TSQLCursor;atransaction:tSQLtransaction; AParams : TParams); virtual; abstract;
|
||||||
|
function RowsAffected(cursor: TSQLCursor): TRowsCount; virtual;
|
||||||
function Fetch(cursor : TSQLCursor) : boolean; virtual; abstract;
|
function Fetch(cursor : TSQLCursor) : boolean; virtual; abstract;
|
||||||
procedure AddFieldDefs(cursor: TSQLCursor; FieldDefs : TfieldDefs); virtual; abstract;
|
procedure AddFieldDefs(cursor: TSQLCursor; FieldDefs : TfieldDefs); virtual; abstract;
|
||||||
procedure UnPrepareStatement(cursor : TSQLCursor); virtual; abstract;
|
|
||||||
|
|
||||||
procedure FreeFldBuffers(cursor : TSQLCursor); virtual;
|
|
||||||
function LoadField(cursor : TSQLCursor;FieldDef : TfieldDef;buffer : pointer; out CreateBlob : boolean) : boolean; virtual; abstract;
|
function LoadField(cursor : TSQLCursor;FieldDef : TfieldDef;buffer : pointer; out CreateBlob : boolean) : boolean; virtual; abstract;
|
||||||
|
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField; cursor: TSQLCursor; ATransaction : TSQLTransaction); virtual; abstract;
|
||||||
|
procedure FreeFldBuffers(cursor : TSQLCursor); virtual;
|
||||||
|
|
||||||
|
Function AllocateTransactionHandle : TSQLHandle; virtual; abstract;
|
||||||
function GetTransactionHandle(trans : TSQLHandle): pointer; virtual; abstract;
|
function GetTransactionHandle(trans : TSQLHandle): pointer; virtual; abstract;
|
||||||
function Commit(trans : TSQLHandle) : boolean; virtual; abstract;
|
function Commit(trans : TSQLHandle) : boolean; virtual; abstract;
|
||||||
function RollBack(trans : TSQLHandle) : boolean; virtual; abstract;
|
function RollBack(trans : TSQLHandle) : boolean; virtual; abstract;
|
||||||
function StartdbTransaction(trans : TSQLHandle; aParams : string) : boolean; virtual; abstract;
|
function StartdbTransaction(trans : TSQLHandle; aParams : string) : boolean; virtual; abstract;
|
||||||
procedure CommitRetaining(trans : TSQLHandle); virtual; abstract;
|
procedure CommitRetaining(trans : TSQLHandle); virtual; abstract;
|
||||||
procedure RollBackRetaining(trans : TSQLHandle); virtual; abstract;
|
procedure RollBackRetaining(trans : TSQLHandle); virtual; abstract;
|
||||||
|
|
||||||
procedure UpdateIndexDefs(IndexDefs : TIndexDefs;TableName : string); virtual;
|
procedure UpdateIndexDefs(IndexDefs : TIndexDefs;TableName : string); virtual;
|
||||||
function GetSchemaInfoSQL(SchemaType : TSchemaType; SchemaObjectName, SchemaPattern : string) : string; virtual;
|
function GetSchemaInfoSQL(SchemaType : TSchemaType; SchemaObjectName, SchemaPattern : string) : string; virtual;
|
||||||
function GetStatementInfo(const ASQL: string; Full: Boolean; ASchema : TSchemaType): TSQLStatementInfo; virtual;
|
|
||||||
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField; cursor: TSQLCursor; ATransaction : TSQLTransaction); virtual; abstract;
|
|
||||||
function RowsAffected(cursor: TSQLCursor): TRowsCount; virtual;
|
|
||||||
Property Statements : TFPList Read FStatements;
|
Property Statements : TFPList Read FStatements;
|
||||||
property Port: cardinal read GetPort write SetPort;
|
property Port: cardinal read GetPort write SetPort;
|
||||||
public
|
public
|
||||||
@ -221,9 +223,9 @@ type
|
|||||||
|
|
||||||
TCustomSQLStatement = Class(TComponent)
|
TCustomSQLStatement = Class(TComponent)
|
||||||
Private
|
Private
|
||||||
FParamCheck: Boolean;
|
|
||||||
FCursor : TSQLCursor;
|
FCursor : TSQLCursor;
|
||||||
FDatabase: TSQLConnection;
|
FDatabase: TSQLConnection;
|
||||||
|
FParamCheck: Boolean;
|
||||||
FParams: TParams;
|
FParams: TParams;
|
||||||
FSQL: TStrings;
|
FSQL: TStrings;
|
||||||
FOrigSQL : String;
|
FOrigSQL : String;
|
||||||
@ -239,8 +241,8 @@ type
|
|||||||
Protected
|
Protected
|
||||||
Function CreateDataLink : TDataLink; virtual;
|
Function CreateDataLink : TDataLink; virtual;
|
||||||
procedure OnChangeSQL(Sender : TObject); virtual;
|
procedure OnChangeSQL(Sender : TObject); virtual;
|
||||||
function GetDataSource: TDatasource; Virtual;
|
function GetDataSource: TDataSource; Virtual;
|
||||||
procedure SetDataSource(AValue: TDatasource); virtual;
|
procedure SetDataSource(AValue: TDataSource); virtual;
|
||||||
Procedure CopyParamsFromMaster(CopyBound : Boolean); virtual;
|
Procedure CopyParamsFromMaster(CopyBound : Boolean); virtual;
|
||||||
procedure AllocateCursor;
|
procedure AllocateCursor;
|
||||||
procedure DeAllocateCursor;
|
procedure DeAllocateCursor;
|
||||||
@ -261,7 +263,7 @@ type
|
|||||||
Property Transaction : TSQLTransaction Read FTransaction Write SetTransaction;
|
Property Transaction : TSQLTransaction Read FTransaction Write SetTransaction;
|
||||||
Property SQL : TStrings Read FSQL Write SetSQL;
|
Property SQL : TStrings Read FSQL Write SetSQL;
|
||||||
Property Params : TParams Read FParams Write SetParams;
|
Property Params : TParams Read FParams Write SetParams;
|
||||||
Property Datasource : TDatasource Read GetDataSource Write SetDataSource;
|
Property DataSource : TDataSource Read GetDataSource Write SetDataSource;
|
||||||
Property ParseSQL : Boolean Read FParseSQL Write FParseSQL;
|
Property ParseSQL : Boolean Read FParseSQL Write FParseSQL;
|
||||||
Property ParamCheck : Boolean Read FParamCheck Write FParamCheck default true;
|
Property ParamCheck : Boolean Read FParamCheck Write FParamCheck default true;
|
||||||
Public
|
Public
|
||||||
@ -278,19 +280,18 @@ type
|
|||||||
TSQLStatement = Class(TCustomSQLStatement)
|
TSQLStatement = Class(TCustomSQLStatement)
|
||||||
Published
|
Published
|
||||||
Property Database;
|
Property Database;
|
||||||
Property Transaction;
|
Property DataSource;
|
||||||
Property SQL;
|
|
||||||
Property Params;
|
|
||||||
Property Datasource;
|
|
||||||
Property ParseSQL;
|
|
||||||
Property ParamCheck;
|
Property ParamCheck;
|
||||||
|
Property Params;
|
||||||
|
Property ParseSQL;
|
||||||
|
Property SQL;
|
||||||
|
Property Transaction;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCustomSQLQuery }
|
{ TCustomSQLQuery }
|
||||||
|
|
||||||
TCustomSQLQuery = class (TCustomBufDataset)
|
TCustomSQLQuery = class (TCustomBufDataset)
|
||||||
private
|
private
|
||||||
// FParamCheck: Boolean;
|
|
||||||
// FCursor : TSQLCursor;
|
// FCursor : TSQLCursor;
|
||||||
FSchemaType: TSchemaType;
|
FSchemaType: TSchemaType;
|
||||||
// FSQL: TStringlist;
|
// FSQL: TStringlist;
|
||||||
@ -331,12 +332,12 @@ type
|
|||||||
function GetSQL: TStringlist;
|
function GetSQL: TStringlist;
|
||||||
function GetStatementType : TStatementType;
|
function GetStatementType : TStatementType;
|
||||||
procedure SetParamCheck(AValue: Boolean);
|
procedure SetParamCheck(AValue: Boolean);
|
||||||
|
procedure SetUpdateSQL(const AValue: TStringlist);
|
||||||
procedure SetDeleteSQL(const AValue: TStringlist);
|
procedure SetDeleteSQL(const AValue: TStringlist);
|
||||||
procedure SetInsertSQL(const AValue: TStringlist);
|
procedure SetInsertSQL(const AValue: TStringlist);
|
||||||
procedure SetParams(AValue: TParams);
|
procedure SetParams(AValue: TParams);
|
||||||
procedure SetParseSQL(AValue : Boolean);
|
procedure SetParseSQL(AValue : Boolean);
|
||||||
procedure SetSQL(const AValue: TStringlist);
|
procedure SetSQL(const AValue: TStringlist);
|
||||||
procedure SetUpdateSQL(const AValue: TStringlist);
|
|
||||||
procedure SetUsePrimaryKeyAsKey(AValue : Boolean);
|
procedure SetUsePrimaryKeyAsKey(AValue : Boolean);
|
||||||
procedure SetUpdateMode(AValue : TUpdateMode);
|
procedure SetUpdateMode(AValue : TUpdateMode);
|
||||||
// procedure OnChangeSQL(Sender : TObject);
|
// procedure OnChangeSQL(Sender : TObject);
|
||||||
@ -364,8 +365,8 @@ type
|
|||||||
Procedure SetActive (Value : Boolean); override;
|
Procedure SetActive (Value : Boolean); override;
|
||||||
procedure SetServerFiltered(Value: Boolean); virtual;
|
procedure SetServerFiltered(Value: Boolean); virtual;
|
||||||
procedure SetServerFilterText(const Value: string); virtual;
|
procedure SetServerFilterText(const Value: string); virtual;
|
||||||
Function GetDataSource : TDatasource; override;
|
Function GetDataSource : TDataSource; override;
|
||||||
Procedure SetDataSource(AValue : TDatasource);
|
Procedure SetDataSource(AValue : TDataSource);
|
||||||
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField); override;
|
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef;ABlobBuf: PBufBlobField); override;
|
||||||
procedure BeforeRefreshOpenCursor; override;
|
procedure BeforeRefreshOpenCursor; override;
|
||||||
procedure SetReadOnly(AValue : Boolean); override;
|
procedure SetReadOnly(AValue : Boolean); override;
|
||||||
@ -421,12 +422,12 @@ type
|
|||||||
property InsertSQL : TStringlist read FInsertSQL write SetInsertSQL;
|
property InsertSQL : TStringlist read FInsertSQL write SetInsertSQL;
|
||||||
property DeleteSQL : TStringlist read FDeleteSQL write SetDeleteSQL;
|
property DeleteSQL : TStringlist read FDeleteSQL write SetDeleteSQL;
|
||||||
property Params : TParams read GetParams Write SetParams;
|
property Params : TParams read GetParams Write SetParams;
|
||||||
|
Property ParamCheck : Boolean Read GetParamCheck Write SetParamCheck default true;
|
||||||
|
property ParseSQL : Boolean read GetParseSQL write SetParseSQL default true;
|
||||||
property UpdateMode : TUpdateMode read FUpdateMode write SetUpdateMode default upWhereKeyOnly;
|
property UpdateMode : TUpdateMode read FUpdateMode write SetUpdateMode default upWhereKeyOnly;
|
||||||
property UsePrimaryKeyAsKey : boolean read FUsePrimaryKeyAsKey write SetUsePrimaryKeyAsKey default true;
|
property UsePrimaryKeyAsKey : boolean read FUsePrimaryKeyAsKey write SetUsePrimaryKeyAsKey default true;
|
||||||
property StatementType : TStatementType read GetStatementType;
|
property StatementType : TStatementType read GetStatementType;
|
||||||
property ParseSQL : Boolean read GetParseSQL write SetParseSQL default true;
|
Property DataSource : TDataSource Read GetDataSource Write SetDataSource;
|
||||||
Property ParamCheck : Boolean Read GetParamCheck Write SetParamCheck default true;
|
|
||||||
Property DataSource : TDatasource Read GetDataSource Write SetDatasource;
|
|
||||||
property ServerFilter: string read FServerFilterText write SetServerFilterText;
|
property ServerFilter: string read FServerFilterText write SetServerFilterText;
|
||||||
property ServerFiltered: Boolean read FServerFiltered write SetServerFiltered default False;
|
property ServerFiltered: Boolean read FServerFiltered write SetServerFiltered default False;
|
||||||
property ServerIndexDefs : TServerIndexDefs read GetServerIndexDefs;
|
property ServerIndexDefs : TServerIndexDefs read GetServerIndexDefs;
|
||||||
@ -478,10 +479,10 @@ type
|
|||||||
property DeleteSQL;
|
property DeleteSQL;
|
||||||
property IndexDefs;
|
property IndexDefs;
|
||||||
property Params;
|
property Params;
|
||||||
|
Property ParamCheck;
|
||||||
|
property ParseSQL;
|
||||||
property UpdateMode;
|
property UpdateMode;
|
||||||
property UsePrimaryKeyAsKey;
|
property UsePrimaryKeyAsKey;
|
||||||
property ParseSQL;
|
|
||||||
Property ParamCheck;
|
|
||||||
Property DataSource;
|
Property DataSource;
|
||||||
property ServerFilter;
|
property ServerFilter;
|
||||||
property ServerFiltered;
|
property ServerFiltered;
|
||||||
@ -677,11 +678,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSQLStatement.SetDataSource(AValue: TDatasource);
|
procedure TCustomSQLStatement.SetDataSource(AValue: TDataSource);
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if GetDatasource=AValue then Exit;
|
if GetDataSource=AValue then Exit;
|
||||||
if (FDataLink=Nil) then
|
if (FDataLink=Nil) then
|
||||||
FDataLink:=CreateDataLink;
|
FDataLink:=CreateDataLink;
|
||||||
FDataLink.DataSource:=AValue;
|
FDataLink.DataSource:=AValue;
|
||||||
@ -722,7 +722,7 @@ end;
|
|||||||
|
|
||||||
procedure TCustomSQLStatement.DoExecute;
|
procedure TCustomSQLStatement.DoExecute;
|
||||||
begin
|
begin
|
||||||
If (FParams.Count>0) and Assigned(Datasource) then
|
If (FParams.Count>0) and Assigned(DataSource) then
|
||||||
CopyParamsFromMaster(False);
|
CopyParamsFromMaster(False);
|
||||||
If LogEvent(detExecute) then
|
If LogEvent(detExecute) then
|
||||||
Log(detExecute,FServerSQL);
|
Log(detExecute,FServerSQL);
|
||||||
@ -912,10 +912,10 @@ begin
|
|||||||
FreeAndNil(FCursor);
|
FreeAndNil(FCursor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomSQLStatement.GetDataSource: TDatasource;
|
function TCustomSQLStatement.GetDataSource: TDataSource;
|
||||||
begin
|
begin
|
||||||
if Assigned(FDataLink) then
|
if Assigned(FDataLink) then
|
||||||
Result:=FDataLink.Datasource
|
Result:=FDataLink.DataSource
|
||||||
else
|
else
|
||||||
Result:=Nil;
|
Result:=Nil;
|
||||||
end;
|
end;
|
||||||
@ -2337,10 +2337,10 @@ begin
|
|||||||
FStatement.Params.Assign(AValue);
|
FStatement.Params.Assign(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomSQLQuery.SetDataSource(AValue: TDatasource);
|
procedure TCustomSQLQuery.SetDataSource(AValue: TDataSource);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
DS : TDatasource;
|
DS : TDataSource;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
DS:=DataSource;
|
DS:=DataSource;
|
||||||
@ -2350,15 +2350,15 @@ begin
|
|||||||
DatabaseError(SErrCircularDataSourceReferenceNotAllowed,Self);
|
DatabaseError(SErrCircularDataSourceReferenceNotAllowed,Self);
|
||||||
If Assigned(DS) then
|
If Assigned(DS) then
|
||||||
DS.RemoveFreeNotification(Self);
|
DS.RemoveFreeNotification(Self);
|
||||||
FStatement.Datasource:=AValue;
|
FStatement.DataSource:=AValue;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomSQLQuery.GetDataSource: TDatasource;
|
function TCustomSQLQuery.GetDataSource: TDataSource;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Assigned(FStatement) then
|
If Assigned(FStatement) then
|
||||||
Result:=FStatement.Datasource
|
Result:=FStatement.DataSource
|
||||||
else
|
else
|
||||||
Result:=Nil;
|
Result:=Nil;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user