Firebird 2.1 - 3 problems

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
rkatze
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 22.05.2009, 23:56

Firebird 2.1 - 3 problems

Post by rkatze »

I'm using Zeos7 with Firebird 2.1 and found 3 problems!

(*1)-There is no way to know if connected successfully,
even without a server running it does not generate exception.

(*2)-In INSERT with invalid data, not write, and does not generate exception.

(*3)-There is a problem when used in the conversion and enhancement of characters Portuguese WIN1252.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
try
   ZConnection1.connect;
except
   begin
   showmessage('Could not open database (1)');  //(*1)does not generate exception
   exit;
   end;
end;

if not ZConnection1.Connected then
   begin
   showmessage('Could not open database (2)'); //(*1)true is not connecting
   exit;
   end;

Zconnection1.StartTransaction;

ZQuery1.SQL.Clear;
ZQuery1.SQL.Append('insert into TBFRUTAS (');
ZQuery1.SQL.Append('FRU_ID,    ');
ZQuery1.SQL.Append('FRU_NAME,  ');
ZQuery1.SQL.Append('FRU_DATE   ');
ZQuery1.SQL.Append(') VALUES(  ');
ZQuery1.SQL.Append('3,         ');
ZQuery1.SQL.Append(Quotedstr('maçã')       + ',');    {"maçã" recorded in the database (*3)}
//ZQuery1.SQL.Append(Quotedstr('05/29/2009') + ')');
ZQuery1.SQL.Append(Quotedstr('05*x9/2x09') + ')');    {is wrong does not generate an error or exception (*2)}


try
   Begin
   ZQuery1.ExecSQL;
   Zconnection1.Commit;
   end
except On E:Exception do
   Begin
   Zconnection1.Rollback;
   MessageDlg(E.Message, mtError, [mbCancel], 0);
   exit;
   end
end;

end;
end.
found and solved problem(*3)

Code: Select all

function PrepareStatement(PlainDriver: IZInterbasePlainDriver;
  Handle: PISC_DB_HANDLE; TrHandle: PISC_TR_HANDLE; Dialect: Word;
  SQL: string; var StmtHandle: TISC_STMT_HANDLE):
  TZIbSqlStatementType;
var
  StatusVector: TARRAY_ISC_STATUS;

  StatementTmp :Ansistring;
begin
  { Allocate an sql statement }
  PlainDriver.isc_dsql_alloc_statement2(@StatusVector, Handle, @StmtHandle);
  CheckInterbase6Error(PlainDriver, StatusVector, lcExecute, Sql);

  { Prepare an sql statement }
  {$IFDEF DELPHI12_UP}
  StatementTmp := UTF8String(SQL);
  PlainDriver.isc_dsql_prepare(@StatusVector, TrHandle, @StmtHandle,
//     0, PAnsiChar(UTF8String(SQL)), Dialect, nil); {<<problem}
     0, PAnsiChar(StatementTmp), Dialect, nil);      {<<solution}
  {$ELSE}
  PlainDriver.isc_dsql_prepare(@StatusVector, TrHandle, @StmtHandle,
     0, PAnsiChar(SQL), Dialect, nil);
  {$ENDIF}
  CheckInterbase6Error(PlainDriver, StatusVector, lcExecute, SQL);

  { Set Statement Type }
  Result := GetStatementType(PlainDriver, StmtHandle);

  if Result in [stUnknown, stGetSegment, stPutSegment, stStartTrans] then
  begin
    FreeStatement(PlainDriver, StmtHandle, DSQL_close);
    raise EZSQLException.Create(SStatementIsNotAllowed);
  end;
end;
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

Hi,

1* I would be interested to know if you have set ZConnection.Database or ZConnection.Hostname, because I tried setting ZConnection.Database but everytime it returns an exception.

Moreover, to know if a server is alive there's method PingServer

2* How have you set ZConnection.TransactionIsolationLevel? tiNone? In this case StartTransaction, Commit and Rollback methods wont work.

3* Solution proposed is not good becasue you use an ANSI string .. which can be good if client and server charsets are the same, but not good if charsets are different
rkatze
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 22.05.2009, 23:56

Post by rkatze »

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin

ZConnection1.AutoCommit             := true;
ZConnection1.Connected              := false;
ZConnection1.Database               := 'C:\DADOS\BDFRUTAS.GDB';
ZConnection1.DesignConnection       := false;
ZConnection1.HostName               := 'localhost';
ZConnection1.LoginPrompt            := false;
ZConnection1.Password               := 'masterkey';
ZConnection1.Port                   := 0;
ZConnection1.Protocol               := 'firebird-2.1';
ZConnection1.ReadOnly               := false;
ZConnection1.TransactIsolationLevel := tiNone;
ZConnection1.User                   := 'SYSDBA';


end;
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

I suppose you have an "old" SVN snapshot because this bug was corrected some times ago ...

Open ZPlainFirebirdDriver.pas and change

function TZFirebird21PlainDriver.isc_interprete(buffer: PAnsiChar;
status_vector: PPISC_STATUS): ISC_STATUS;
var
bufsize : integer;
begin
bufsize := 1024;
Result := FIREBIRD_API.fb_interpret(buffer, bufsize, status_vector);
end;
rkatze
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 22.05.2009, 23:56

Post by rkatze »

updated svn and now it all working.

Your help was very inportante for me.

thank you very much.
Locked