Page 1 of 2

[patch_done] Overwrite Records in Tables

Posted: 10.05.2011, 21:59
by rvgugisch
Good afternoon,

I'm using Zeos Delphi 7 + 7 + UserControl + PostgreSQL 8.x on Windows XP.

Now that a larger volume of data in the database records when altered, are being replaced by others who can not identify where le handle.
That is, my database is being overwritten with informations about random.

I am being forced to using and enjoying the alpha version of Zeos UserControl because that component with the stable version does not work correctly.

I wonder if there is any complaint about that? And if there is a solution to it?
:cry:

Posted: 11.05.2011, 12:37
by trupka
Hi,

I'm sorry, it's very hard to understand from your post what issue do you have..
Can you rephrase question? Code sample maybe?

Posted: 11.05.2011, 12:51
by rvgugisch
Sorry for bad English.

I am now with enough records to test the beta version of ZEOS.

What is happening is it override existing records when I edit a particular record.

When I call a POST ZEOS overrides the record I'm editing with data from another record.

I have overlap occurs because the code inside the component ZEOS and not in my program.

In debugging the error occurs on ZDBCStatment.pas.

Can not find exactly where the overwrite occurs.

Posted: 11.05.2011, 16:23
by rvgugisch
Find my problem!

http://zeosbugs.firmos.at/view.php?id=106

My Zeos 7.0 + Delphi 7 + PostgreSQL 8.4

Posted: 11.05.2011, 16:28
by rvgugisch
but the solution in url above not works.

Posted: 11.05.2011, 17:29
by trupka
rvgugisch,
Can you make and post some simple example to reproduce problem?
Pascal is language we both understand... :-)

Posted: 11.05.2011, 21:18
by rvgugisch
Ok.

In my system, table Orders have a filter and SortedFields.

Code: Select all

    MessageDlg('BEFORE POST ' + #13 + #13 +
               'ID ' + frmPrincipal.MySQLOrdensid.AsString + #13 +
               'RecNo ' + IntToStr( frmPrincipal.MySQLOrdens.RecNo) + #13 +
               'CNPJ ' + frmPrincipal.MySQLOrdenscnpj.Text + #13 +
               'Cod Vend ' + frmPrincipal.MySQLOrdenscod_vend.Text + #13 +
               'Cod Produto ' + frmPrincipal.MySQLOrdensproduto.Text + #13 +
               'Cod Status ' + frmPrincipal.MySQLOrdensstatus.Text + #13 +
               'Dt Status ' + frmPrincipal.MySQLOrdensdt_mudanca.AsString + #13 +
               'Dt Entrada ' + frmPrincipal.MySQLOrdensdt_entrada.AsString
               , mtWarning, [mbOK], 0);
      dsVisao.DataSet.Post;
    MessageDlg('AFTER POST ' + #13 + #13 +
               'ID ' + frmPrincipal.MySQLOrdensid.AsString + #13 +
               'RecNo ' + IntToStr( frmPrincipal.MySQLOrdens.RecNo) + #13 +
               'CNPJ ' + frmPrincipal.MySQLOrdenscnpj.Text + #13 +
               'Cod Vend ' + frmPrincipal.MySQLOrdenscod_vend.Text + #13 +
               'Cod Produto ' + frmPrincipal.MySQLOrdensproduto.Text + #13 +
               'Cod Status ' + frmPrincipal.MySQLOrdensstatus.Text + #13 +
               'Dt Status ' + frmPrincipal.MySQLOrdensdt_mudanca.AsString + #13 +
               'Dt Entrada ' + frmPrincipal.MySQLOrdensdt_entrada.AsString
               , mtWarning, [mbOK], 0);
My filter:

Code: Select all

   dsVisao.DataSet.Filter := 'Upper( Tipo ) = ' + QuotedStr('FIXA')
     + ' OR Upper( Tipo ) = ' + QuotedStr('FIXA');
   dsVisao.DataSet.Filtered := True;

The information is different in the dialogues of BEFORE and AFTER, mainly RecN.

When I insert a record inder it normally, but the position of the table remains the record that I was before the insert.

When I change a record, the table leaves the current record and other changes.

Posted: 12.05.2011, 00:37
by trupka
Try this patch

Code: Select all

Index: src/component/ZAbstractDataset.pas
===================================================================
--- src/component/ZAbstractDataset.pas	(revision 891)
+++ src/component/ZAbstractDataset.pas	(working copy)
@@ -475,6 +475,7 @@
       FreeFieldBuffers;
       SetState(dsBrowse);
       Resync([]);
+      BM := Bookmark;
       if BookmarkValid(@BM) Then
       begin 
         InternalGotoBookmark(@BM); 

Posted: 19.05.2011, 22:04
by mdaems
Did this solve the issue?

Posted: 20.05.2011, 08:12
by trupka
Hi Mark,
in original code InternalGotoBookmark(@BM) never happens because BM var is never used. In that sense, my patch solves row jumping problem but I didnt do any serious testing (and I'm not using filters in my apps so I can't be 100% sure, but, in other hand, can't be worse than without patch :-) )

Posted: 20.05.2011, 14:20
by ism
rvgugisch

Put please a sample project wich demonstrates the problem, and database structure and data script

Posted: 26.10.2011, 21:56
by rvgugisch
Sorry for the lack of answers.

I solved the problem by simply not using the filter tables.

Posted: 20.03.2012, 15:46
by Shagrat3
Do you test code anytime?

In Delphi XE2 - Not work

Fix:
BM - initialize
@BM - {$IFDEF DELPHI12_UP}BM{$ELSE}@BM{$ENDIF}

Code: Select all

    if (SortedFields <> '') and not (doDontSortOnPost in Options) then begin

      FreeFieldBuffers;
      SetState(dsBrowse);
      Resync([]);
      BM := Bookmark;
      if BookmarkValid(BM) Then begin
        InternalGotoBookmark(BM);
        Resync([rmExact, rmCenter]);
      end;
      DisableControls;
      InternalSort;
      BookMark:=BM;
      UpdateCursorPos;
      EnableControls;
    end;

Posted: 22.03.2012, 22:14
by EgonHugeist
Can you make a TortoisSVN-Patch eventually?

Posted: 23.03.2012, 06:05
by Shagrat3
This patch not adapted for other delphi version. Tested only for Delphi XE

Code: Select all

Index: ZAbstractDataset.pas
===================================================================
--- ZAbstractDataset.pas	(revision 1089)
+++ ZAbstractDataset.pas	(working copy)
@@ -468,16 +468,16 @@
       InternalUpdate;
 
     {BUG-FIX: bangfauzan addition}
-    if (SortedFields <> '') and not (doDontSortOnPost in Options) then
-    begin
+    if (SortedFields <> '') and not (doDontSortOnPost in Options) then begin
+
       FreeFieldBuffers;
       SetState(dsBrowse);
       Resync([]);
-      if BookmarkValid(@BM) Then
-      begin 
-        InternalGotoBookmark(@BM); 
-        Resync([rmExact, rmCenter]); 
-      end; 
+      BM := Bookmark;
+      if BookmarkValid({$IFDEF DELPHI12_UP}BM{$ELSE}@BM{$ENDIF}) Then begin
+        InternalGotoBookmark({$IFDEF DELPHI12_UP}BM{$ELSE}@BM{$ENDIF});
+        Resync([rmExact, rmCenter]);
+      end;
       DisableControls;
       InternalSort;
       BookMark:=BM;