Page 1 of 1

Error to do Update, using the same ZConnection in a While

Posted: 01.08.2011, 20:38
by JavaPauloMG
Hello,

I still convert all programs, to ZeosLib 6.6.6, but i found a strange problemn, in this code, when the "Next" statement is called, but in DBX this code Works, and in many applications this logic are used, i do something wrong?

Code: Select all

procedure TFi000.btnClick(Sender: TObject);
var
  query1 : TZReadOnlyQuery;
  query2 : TZQuery;
begin

  Cursor := crHourGlass;

  query1 := TZReadOnlyQuery.Create(nil);
  query2 := TZQuery.Create(nil);

  query1.Connection := Dmaih.SQLDados;
  query2.Connection := Dmaih.SQLDados;

  query1.SQL.Clear();
  query1.SQL.Add('select * from RDB$FIELDS');

  query1.Open();

  while not query1.Eof do begin

    query2.Connection.StartTransaction();

    query2.SQL.Clear();

    query2.SQL.Add('update RDB$FIELDS set RDB$QUERY_NAME=:RDB$QUERY_NAME where RDB$FIELD_NAME=:RDB$FIELD_NAME');

    query2.ParamByName('RDB$QUERY_NAME').AsString := query1.FieldByName('RDB$QUERY_NAME').AsString;
    query2.ParamByName('RDB$FIELD_NAME').AsString := query1.FieldByName('RDB$FIELD_NAME').AsString;

    query2.ExecSQL();

    query2.Connection.Commit();

    query1.Next();

  end;

  FreeAndNil(query1);
  FreeAndNil(query2);

  Cursor := crDefault;  

end;
Thanks to all.

Posted: 01.08.2011, 22:38
by guidoaerts
don't know, but after query.open I always do query.first to locate cursor on first record. don't know if query.open creates cursor in zreadonlyquery...
(just found out that lazarus 0.9.28.2; fpc 2.2.4 and zeos 6.6.6-stable gives problems with 'bookmarks'... will report later)
guido

Posted: 02.08.2011, 13:32
by JavaPauloMG
This realy strange, in DBX its works, but now it's is the problem, i convert 20 app, and all use this logic, if i put a diferent connection to query it works, but my convert process now is more slow...

Posted: 02.08.2011, 16:01
by guidoaerts
JavaPauloMG, i copied your code into a new app in delphi5, with zeos665-stable on winxp sp2 with a fb2.1 database. it works ok, without error!
guido

Posted: 02.08.2011, 17:49
by JavaPauloMG
I will show my connections params, maybe it can be i use hard_commit = true.

Code: Select all

    wConnection.TransactIsolationLevel := tiReadCommitted;
    wConnection.HostName := '127.0.0.1';
    wConnection.Database := '';
    wConnection.User     := 'SYSDBA'
    wConnection.Password := 'masterkey';
    wConnection.Protocol := 'firebird-1.5';
    wConnection.Properties.Clear();    
    wConnection.Properties.Add('hard_commit=yes');
    wConnection.Properties.Add('dialect=3');
Thanks

Posted: 03.08.2011, 15:45
by JavaPauloMG
I discover the error, this only occours when i set "wConnection.Properties.Add('hard_commit=yes');" in the connection,
but i need this statement, to convert, and use the same behavior of DBX, now the question is, is a error of experimental hard_commit=yes?
I know i need to change my architeture, to every query use a single connection, but the DBX support many querys in onyl single connection :-( its sad bu it's true...

Posted: 03.08.2011, 16:36
by guidoaerts
Well with me it works fine wether I add the properties or not. Maybe it is related to fb1.5.
Concerning hard and soft commit, I suggest you read this:

http://tech.groups.yahoo.com/group/fire ... sage/34797

(Helen is/was(?) member of the development group of firebird.)
Guido