I use datawindow update function to insert data into table after i get id max but some time the follwoing happen: id | field a | field b | field c | 1 4 6 7 2 4 6 7 I check may code and debug without insert repeat i can't avoid the insertion of duplicate rows I am using powerbuilder 11 ,and SQLAnywhere 12 |
Show us the PowerBuilder code; please copy and paste the exact code, do not edit it.
Besides that, may there be an INSERT trigger that may duplicate a row internally?
I am sure that no triggers on this table
@eraqaty: I have formatted your code - it's quite easy within a comment by enclosing your code with a <pre> ... </pre> tag pair. (It's even simpler for questions/anwers by using the "CODE" button from the edit toolbar...)
Please show us the code for wf_save() and u_add(), and explain how ids_LGMod is used.
The second argument in the dw_1.Update( True, False ) call overrides the resetflag default value of True, setting it to False, which means that the row update flags will not be reset even if the call works... which means a second call to Update will do the same work over again. This is VERY unusual; 99.99% of the world's calls to Update look like this: dw_1.Update().
The code you have posted is quite complex... there are calls to several other methods (wf_save(), u_add(), ids_LGMod.Update()) for which the code is not shown.
Given the history of PowerBuilder and SQL Anywhere, the probability that this inserting-duplicate-rows-problem is caused by a bug in either product is 0.000001%.
It is much more likely that the application code contains another Update() call that is inserting the duplicate... or that the code shown is being executed twice, perhaps via accidental recursion.
It is a fundamental problem of most "modern" object-oriented code that the logic to do one simple thing (update a datawindow) is spread across several, sometimes dozens, of separate methods located in different libraries. If you show us ALL the related methods, perhaps we can help you find the problem. Good luck!
Assuming that you have inherited the datawindow object, can you also post the error information reported in the DBError event? This error might explain in more detail the start of the behaviour you are seeing. If that is not available, perhaps a -zr sql (can be enabled from code) to see what error is being reported.
Also, is this table updated by more than one connection at a time? If so, you would be better served using autoincrement values rather than calculating a max() value.
"ids_LGMod " only datastore to update in onther table // Update properties Key and Updatable Columns ,Use Update //
yes this table used by more users with more than one connection but please note that 2 duplicate rows have different id (max) but have the same data in all other columns DBError as following: