mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-28 12:19:27 +02:00
fcl-db: sqldb: cosmetic
git-svn-id: trunk@27257 -
This commit is contained in:
parent
e8de259b63
commit
285d459801
@ -693,8 +693,8 @@ var
|
|||||||
hour : word;
|
hour : word;
|
||||||
begin
|
begin
|
||||||
DecodeTime(Time,hour,minute,second,millisecond);
|
DecodeTime(Time,hour,minute,second,millisecond);
|
||||||
hour := hour + (trunc(Time) * 24);
|
hour := hour + trunc(Time)*24;
|
||||||
result := Format('%.2d:%.2d:%.2d.%.3d',[hour,minute,second,millisecond]);
|
Result := Format('%.2d:%.2d:%.2d.%.3d',[hour,minute,second,millisecond]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TSQLDBFieldDefs }
|
{ TSQLDBFieldDefs }
|
||||||
@ -1033,10 +1033,24 @@ end;
|
|||||||
|
|
||||||
{ TSQLConnection }
|
{ TSQLConnection }
|
||||||
|
|
||||||
|
constructor TSQLConnection.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FSQLFormatSettings:=DefaultSQLFormatSettings;
|
||||||
|
FFieldNameQuoteChars:=DoubleQuotes;
|
||||||
|
FLogEvents:=LogAllEvents; //match Property LogEvents...Default LogAllEvents
|
||||||
|
FStatements:=TFPList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TSQLConnection.Destroy;
|
||||||
|
begin
|
||||||
|
Connected:=False; // needed because we want to de-allocate statements
|
||||||
|
FreeAndNil(FStatements);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
function TSQLConnection.StrToStatementType(s : string) : TStatementType;
|
function TSQLConnection.StrToStatementType(s : string) : TStatementType;
|
||||||
|
|
||||||
var T : TStatementType;
|
var T : TStatementType;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
S:=Lowercase(s);
|
S:=Lowercase(s);
|
||||||
for T:=stSelect to stRollback do
|
for T:=stSelect to stRollback do
|
||||||
@ -1060,9 +1074,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLConnection.UpdateIndexDefs(IndexDefs : TIndexDefs; TableName : string);
|
procedure TSQLConnection.UpdateIndexDefs(IndexDefs : TIndexDefs; TableName : string);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// Empty abstract
|
// Empty abstract
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSQLConnection.DoInternalConnect;
|
procedure TSQLConnection.DoInternalConnect;
|
||||||
@ -1082,13 +1095,6 @@ begin
|
|||||||
FStatements.Clear;
|
FStatements.Clear;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSQLConnection.Destroy;
|
|
||||||
begin
|
|
||||||
Connected:=False; // needed because we want to de-allocate statements
|
|
||||||
FreeAndNil(FStatements);
|
|
||||||
inherited Destroy;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSQLConnection.StartTransaction;
|
procedure TSQLConnection.StartTransaction;
|
||||||
begin
|
begin
|
||||||
if not assigned(Transaction) then
|
if not assigned(Transaction) then
|
||||||
@ -1186,15 +1192,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor TSQLConnection.Create(AOwner: TComponent);
|
|
||||||
begin
|
|
||||||
inherited Create(AOwner);
|
|
||||||
FSQLFormatSettings:=DefaultSQLFormatSettings;
|
|
||||||
FFieldNameQuoteChars:=DoubleQuotes;
|
|
||||||
FLogEvents:=LogAllEvents; //match Property LogEvents...Default LogAllEvents
|
|
||||||
FStatements:=TFPList.Create;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSQLConnection.GetTableNames(List: TStrings; SystemTables: Boolean);
|
procedure TSQLConnection.GetTableNames(List: TStrings; SystemTables: Boolean);
|
||||||
begin
|
begin
|
||||||
if not SystemTables then
|
if not SystemTables then
|
||||||
@ -1402,23 +1399,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TSQLConnection.GetAsSQLText(Field : TField) : string;
|
function TSQLConnection.GetAsSQLText(Field : TField) : string;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (not assigned(field)) or field.IsNull then Result := 'Null'
|
if (not assigned(Field)) or Field.IsNull then Result := 'Null'
|
||||||
else case field.DataType of
|
else case field.DataType of
|
||||||
ftString : Result := QuotedStr(Field.AsString);
|
ftString : Result := QuotedStr(Field.AsString);
|
||||||
ftDate : Result := '''' + FormatDateTime('yyyy-mm-dd',Field.AsDateTime,FSqlFormatSettings) + '''';
|
ftDate : Result := '''' + FormatDateTime('yyyy-mm-dd',Field.AsDateTime,FSqlFormatSettings) + '''';
|
||||||
ftDateTime : Result := '''' + FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz',Field.AsDateTime,FSqlFormatSettings) + '''';
|
ftDateTime : Result := '''' + FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz',Field.AsDateTime,FSqlFormatSettings) + '''';
|
||||||
ftTime : Result := QuotedStr(TimeIntervalToString(Field.AsDateTime));
|
ftTime : Result := QuotedStr(TimeIntervalToString(Field.AsDateTime));
|
||||||
else
|
else
|
||||||
Result := field.asstring;
|
Result := Field.AsString;
|
||||||
end; {case}
|
end; {case}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSQLConnection.GetAsSQLText(Param: TParam) : string;
|
function TSQLConnection.GetAsSQLText(Param: TParam) : string;
|
||||||
begin
|
begin
|
||||||
if (not assigned(param)) or param.IsNull then Result := 'Null'
|
if (not assigned(Param)) or Param.IsNull then Result := 'Null'
|
||||||
else case param.DataType of
|
else case Param.DataType of
|
||||||
ftGuid,
|
ftGuid,
|
||||||
ftMemo,
|
ftMemo,
|
||||||
ftFixedChar,
|
ftFixedChar,
|
||||||
@ -1431,7 +1427,7 @@ begin
|
|||||||
ftFloat : Result := FloatToStr(Param.AsFloat, FSQLFormatSettings);
|
ftFloat : Result := FloatToStr(Param.AsFloat, FSQLFormatSettings);
|
||||||
ftFMTBcd : Result := stringreplace(Param.AsString, DefaultFormatSettings.DecimalSeparator, FSQLFormatSettings.DecimalSeparator, []);
|
ftFMTBcd : Result := stringreplace(Param.AsString, DefaultFormatSettings.DecimalSeparator, FSQLFormatSettings.DecimalSeparator, []);
|
||||||
else
|
else
|
||||||
Result := Param.asstring;
|
Result := Param.AsString;
|
||||||
end; {case}
|
end; {case}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1510,7 +1506,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TSQLConnection.ConstructUpdateSQL(Query: TCustomSQLQuery) : string;
|
function TSQLConnection.ConstructUpdateSQL(Query: TCustomSQLQuery): string;
|
||||||
|
|
||||||
var x : integer;
|
var x : integer;
|
||||||
F : TField;
|
F : TField;
|
||||||
@ -1811,7 +1807,7 @@ Var
|
|||||||
M : String;
|
M : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If LogEVent(EventType) then
|
If LogEvent(EventType) then
|
||||||
begin
|
begin
|
||||||
If (Name<>'') then
|
If (Name<>'') then
|
||||||
M:=Name+' : '+Msg
|
M:=Name+' : '+Msg
|
||||||
|
Loading…
Reference in New Issue
Block a user