-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathu_DBMS_Utils.pas
87 lines (70 loc) · 1.8 KB
/
u_DBMS_Utils.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
unit u_DBMS_Utils;
{$include i_DBMS.inc}
interface
uses
Windows,
SysUtils,
t_types;
function AnsiStrToDB(const S: AnsiString): AnsiString;
function WideStrToDB(const S: WideString): WideString;
function DBMSStrToDB(const S: TDBMS_String): TDBMS_String; inline;
function GetModuleFileNameWithoutExt(
const AInSqlSubFolder: Boolean;
const AKeepFullPath: Boolean;
const APrefixBefore: String;
const ATailAfterDot: String
): String;
function NowUTC: TDateTime;
implementation
uses
t_DBMS_Template;
function AnsiStrToDB(const S: AnsiString): AnsiString;
begin
Result := QuotedStr(S);
end;
function WideStrToDB(const S: WideString): WideString;
var
I: Integer;
begin
Result := S;
for I := Length(Result) downto 1 do
if Result[I] = '''' then Insert('''', Result, I);
Result := '''' + Result + '''';
end;
function DBMSStrToDB(const S: TDBMS_String): TDBMS_String; inline;
begin
{$if defined(USE_WIDESTRING_FOR_SQL)}
Result := WideStrToDB(S);
{$else}
Result := QuotedStr(S);
{$ifend}
end;
function GetModuleFileNameWithoutExt(
const AInSqlSubFolder: Boolean;
const AKeepFullPath: Boolean;
const APrefixBefore: String;
const ATailAfterDot: String
): String;
begin
Result := GetModuleName(HInstance);
if (not AKeepFullPath) then begin
Result := ExtractFileName(Result);
end;
Result := ChangeFileExt(Result,'');
if (0<Length(ATailAfterDot)) then begin
Result := Result + '.' + ATailAfterDot;
end;
if (0<Length(APrefixBefore)) then begin
Result := APrefixBefore + Result;
end;
if AInSqlSubFolder then begin
Result := c_SQL_SubFolder + Result;
end;
end;
function NowUTC: TDateTime;
var st: TSystemTime;
begin
GetSystemTime(st);
Result := SystemTimeToDateTime(st);
end;
end.