[patch_done] Overwrite Records in Tables

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

rvgugisch
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.05.2011, 21:47

[patch_done] Overwrite Records in Tables

Post 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:
Last edited by rvgugisch on 26.10.2011, 21:57, edited 1 time in total.
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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?
rvgugisch
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.05.2011, 21:47

Post 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.
rvgugisch
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.05.2011, 21:47

Post by rvgugisch »

Find my problem!

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

My Zeos 7.0 + Delphi 7 + PostgreSQL 8.4
rvgugisch
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.05.2011, 21:47

Post by rvgugisch »

but the solution in url above not works.
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

rvgugisch,
Can you make and post some simple example to reproduce problem?
Pascal is language we both understand... :-)
rvgugisch
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.05.2011, 21:47

Post 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.
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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); 
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Did this solve the issue?
Image
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post 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 :-) )
ism
Zeos Test Team
Zeos Test Team
Posts: 202
Joined: 02.10.2010, 20:48

Post by ism »

rvgugisch

Put please a sample project wich demonstrates the problem, and database structure and data script
Lazarus 1.0.8 fpc 2.6.0
rvgugisch
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.05.2011, 21:47

Post by rvgugisch »

Sorry for the lack of answers.

I solved the problem by simply not using the filter tables.
Shagrat3
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 28.07.2009, 16:02
Contact:

Post 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;
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

Can you make a TortoisSVN-Patch eventually?
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
Shagrat3
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 28.07.2009, 16:02
Contact:

Post 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;
Locked