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 Delphi. Older versions lack regular expression |
398 |
+ |
handling.} |
399 |
+ |
function ExtractConnectString(const CreateSQL: AnsiString; |
400 |
+ |
var ConnectString: AnsiString): boolean; |
401 |
+ |
var i: integer; |
402 |
+ |
begin |
403 |
+ |
Result := false; |
404 |
+ |
i := Pos('''',CreateSQL); |
405 |
+ |
if i > 0 then |
406 |
+ |
begin |
407 |
+ |
ConnectString := CreateSQL; |
408 |
+ |
delete(ConnectString,1,i); |
409 |
+ |
i := Pos('''',ConnectString); |
410 |
+ |
if i > 0 then |
411 |
+ |
begin |
412 |
+ |
delete(ConnectString,i,Length(ConnectString)-i+1); |
413 |
+ |
Result := true; |
414 |
+ |
end; |
415 |
+ |
end; |
416 |
+ |
end; |
417 |
+ |
{$ENDIF} |
418 |
|
|
419 |
|
{Format an SQL Identifier according to SQL Dialect with encapsulation if necessary} |
420 |
|
|