33 |
|
|
34 |
|
unit IBUtils; |
35 |
|
{$IFDEF MSWINDOWS} |
36 |
< |
{$DEFINE WINDOWS} |
36 |
> |
{$DEFINE WINDOWS} |
37 |
|
{$ENDIF} |
38 |
|
|
39 |
|
{$IFDEF FPC} |
40 |
|
{$Mode Delphi} |
41 |
|
{$codepage UTF8} |
42 |
+ |
{$define HASREQEX} |
43 |
|
{$ENDIF} |
44 |
|
|
45 |
+ |
|
46 |
|
interface |
47 |
|
|
48 |
|
uses Classes, SysUtils; |
270 |
|
|
271 |
|
implementation |
272 |
|
|
273 |
+ |
{$IFDEF HASREQEX} |
274 |
|
uses RegExpr; |
275 |
+ |
{$ENDIF} |
276 |
|
|
277 |
|
function Max(n1, n2: Integer): Integer; |
278 |
|
begin |
375 |
|
|
376 |
|
{Extracts the Database Connect string from a Create Database Statement} |
377 |
|
|
378 |
+ |
{$IFDEF HASREQEX} |
379 |
|
function ExtractConnectString(const CreateSQL: AnsiString; |
380 |
|
var ConnectString: AnsiString): boolean; |
381 |
|
var RegexObj: TRegExpr; |
393 |
|
RegexObj.Free; |
394 |
|
end; |
395 |
|
end; |
396 |
+ |
{$ELSE} |
397 |
+ |
{cruder version of above for old versions of Delphi} |
398 |
+ |
function ExtractConnectString(const CreateSQL: AnsiString; |
399 |
+ |
var ConnectString: AnsiString): boolean; |
400 |
+ |
var i: integer; |
401 |
+ |
begin |
402 |
+ |
Result := false; |
403 |
+ |
i := Pos('''',CreateSQL); |
404 |
+ |
if i > 0 then |
405 |
+ |
begin |
406 |
+ |
ConnectString := CreateSQL; |
407 |
+ |
delete(ConnectString,1,i); |
408 |
+ |
i := Pos('''',ConnectString); |
409 |
+ |
if i > 0 then |
410 |
+ |
begin |
411 |
+ |
delete(ConnectString,i,Length(ConnectString)-i+1); |
412 |
+ |
Result := true; |
413 |
+ |
end; |
414 |
+ |
end; |
415 |
+ |
end; |
416 |
+ |
{$ENDIF} |
417 |
|
|
418 |
|
{Format an SQL Identifier according to SQL Dialect with encapsulation if necessary} |
419 |
|
|