How to query a Firebird SQL dialog box

I am trying to query the SQL dialect of the Firebird database (using the built-in driver):

procedure TFrmFireDACEmbed.BtnGetDBDialectClick(Sender: TObject);
var
   lFDConnection : TFDConnection;
   lDriverLink   : TFDPhysFBDriverLink;
   l             : Integer;
begin
   if not DlgOpen.Execute then Exit;

   lDriverLink   := TFDPhysFBDriverLink.Create(nil);
   lFDConnection := TFDConnection.Create(nil);
   try
      lDriverLink.DriverID := 'FBEmbedded';
      lDriverLink.VendorLib := 'fbembed.dll';  // 32-bits embedded
      lFDConnection.DriverName := S_FD_FBId;
      lFDConnection.Params.Database := DlgOpen.FileName;
      lFDConnection.Params.Add('Server=127.0.0.1');
      lFDConnection.Params.UserName := 'SYSDBA';
      lFDConnection.Params.Password := 'masterkey';
      lFDConnection.LoginPrompt := False;
      lFDConnection.Open;
      l := lFDConnection.Params.IndexOf('SQLDialect');
      if l <> -1 then
         ShowMessage(lFDConnection.Params[l])
      else
         ShowMessage('SQLDialect not found');
   finally
      lFDConnection.Close;
      lFDConnection.Free;
      lDriverLink.Free;
   end;
end;

But lFDConnection.Paramsonly contains DriverID, Database, Server, User_Name, Password.

The inspector shows:

(nil, $2F22820, #$D#$A, nil, 0, ',', '"', '=', [soWriteBOM,soTrailingLineBreak,soUseLocale], (('DriverID=FB', nil), ('Database=D:\Temp\KLANTEN.GDB', nil), ('Server=127.0.0.1', nil), ('User_Name=SYSDBA', nil), ('Password=masterkey', nil), ('', nil), ('', nil), ('', nil)), 5, 8, False, dupIgnore, False, (FireDAC.Stan.Def.TFDDefinition.ParamsChanged,$2F5C4F0), (FireDAC.Stan.Def.TFDDefinition.ParamsChanging,$2F5C4F0), False, TFDConnectionDef($2F5C534) as IFDStanDefinition)

And lFDConnection.Params.SQLDialectnot recognized by the compiler.

Digging through the system tables, I found that for a 3 dB dialect

select mon$sql_dialect from mon$database

will return 3, but for an older version mon$databasedoes not exist.

How can I get an SQL dialect for any dialect?

The goal is to rewrite old code that used functions "under the hood", such as isc_attach_database, isc_database_info(which were supposed to be dynamically linked, GetProcAddressetc.).

+4
source
2

SQL Firebird?

- :

uses
  FireDAC.Phys.IBWrapper;

procedure TForm1.Button1Click(Sender: TObject);
var
  SQLDialect: Integer;
  IBDatabase: TIBDatabase;
begin
  IBDatabase := TObject(FDConnection1.CliObj) as TIBDatabase;
  SQLDialect := IBDatabase.db_sql_dialect;
end;

SQL Firebird ?

SQL:

FDConnection1.Params.Add('SQLDialect=1');

Firebird :

TFDPhysFBConnectionDefParams(FDConnection1.Params).SQLDialect := 1;
+2

Delphi, Firebird.

MON$DATABASE 1, 3, , , , ODS 11.1 (Firebird 2.1, ). MON$DATABASE, - ODS 10.0 (InterBase 6/Firebird 1.x) ODS 11.0 (Firebird 2.0).

, MON$DATABASE, , MON$DATABASE.

, , , 1 . , :

select 1/2 from rdb$database

0 (integer), 3, 0.500000 ( ), - 1. , DOUBLE PRECISION 1 BIGINT ( DECIMAL(18,0)) 3.

, 1 3: 1 .

: . , / .

isc_info_db_sql_dialect isc_database_info ( , -, , . )., gstat -h, .

+1

Source: https://habr.com/ru/post/1695149/


All Articles