#1 2018-10-29 19:40:09

triguinhu
Member
From: Brazil
Registered: 2016-07-28
Posts: 27

Sample 16 - Execute SQL via Services problem

Hi all,

I changed example 16 to work with firebird, but I have received this error

First chance exception at $779017D2. Exception class EInterfaceFactoryException with message
'TInterfacedObjectFakeClient.FakeCall(IRemoteSQL.Execute) failed: '{
"errorCode":500,
"error":
{"EFirebirdException":{
"ClassName":"EFirebirdException",
"Address":"004D25F7 ",
"Message": "Firebird Error 140000F9: Dynamic SQL Error. SQL error code = -502. Invalid cursor declaration. Statement already has a cursor SYNDB assigned. [ SQLCODE=-502 (The cursor identified in an OPEN statement is already open.) ]"
}}
}''.
Process ProComm.exe (8308)

I believe it is some failure of my implementation, I need help to get out of this dead end

My SQL Interface

unit U_SQL_Interface;

interface

uses
  SynCommons,
  mORMot;

type
  TRemoteSQLEngine = (rseOleDB, rseODBC, rseOracle, rseSQlite3, rseJet, rseFireBird, rseMSSQL);

  IRemoteSQL = interface(IInvokable)
    ['{7CEFA011-7EDD-44F0-9802-DC4F25365D71}']
    procedure Connect(aEngine: TRemoteSQLEngine; const aServerName, aDatabaseName,
      aUserID, aPassWord: RawUTF8);
    function GetTableNames: TRawUTF8DynArray;
    function Execute(const aSQL: RawUTF8; aExpectResults, aExpanded: Boolean): RawJSON;
  end;

const
  ROOT_NAME = 'rootServ01';
  PORT_NAME = '8085';

implementation

end.

{ TServiceRemoteSQL }

procedure TServiceRemoteSQL.Connect(aEngine: TRemoteSQLEngine;
  const aServerName, aDatabaseName, aUserID, aPassWord: RawUTF8);
const // rseOleDB, rseODBC, rseOracle, rseSQlite3, rseJet, rseMSSQL
//(rseOleDB, rseODBC, rseOracle, rseSQlite3, rseJet, rseFireBird, rseMySQL, rsePostGreSQL, rseMSSQL);
  TYPES: array[TRemoteSQLEngine] of TSQLDBConnectionPropertiesClass = (
     TOleDBConnectionProperties, TODBCConnectionProperties,
     TSQLDBOracleConnectionProperties, TSQLDBSQLite3ConnectionProperties,
     {$ifdef WIN64}nil{$else}TOleDBJetConnectionProperties{$endif},
     TSQLDBFirebirdConnectionProperties,
     TOleDBMSSQL2008ConnectionProperties);
begin
  if fProps<>nil then
    raise Exception.Create('Connect called more than once');
  if TYPES[aEngine]=nil then
    raise Exception.CreateFmt('aEngine=%s is not supported',
      [GetEnumName(TypeInfo(TRemoteSQLEngine),ord(aEngine))^]);
  fProps := TYPES[aEngine].Create(aServerName,aDatabaseName,aUserID,aPassWord);
end;

Connect Call

  fSettings.fEngine := rseFireBird;
  fSettings.fServerName := StringToUTF8('localhost/3050:C:\Commerce\Database\Procomm.gdb');
  fSettings.fDatabaseName := '';
  fSettings.fUserID := StringToUTF8('sysdba');
  fSettings.fPassword := StringToUTF8('masterkey');
  with fSettings do
    fService.Connect(Engine,ServerName,DatabaseName,UserID,PassWord);

Call that the error occurs

    fService.Execute('SELECT * FROM EMPRESAS',True,False);

What is my mistake?

Thanks

Offline

#2 2018-10-30 00:29:40

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Sample 16 - Execute SQL via Services problem

IIRC TSQLDBFirebirdConnectionProperties is not finished, and not running - it is clearly documented as such.

The best is to use SynDBZeos and the Zeos/ZDBC library to connect to FireBird.

Offline

Board footer

Powered by FluxBB