View previous topic :: View next topic
|
Author |
Message |
Ziko13
New User
Joined: 19 Jul 2018 Posts: 26 Location: Greece
|
|
|
|
Hi all,
I have a program in which the users are seeing data from a database (in a map) and are able to change or add records.
At first the program is filling the map with data that are already in the database and then , after the enter key has been pressed, it is getting all the data from the map and inserts into the database.
My problem is that I cannot specify when the data is coming from the database , therefore should not be inserted again , and when they are coming from a user action , therefore are new records to be inserted.
I tried checking the length field of a map field greater than zero but still data are inserted twice because when it receives data from the database it is getting set to greater than zero.
I do not have a duplicate error because i have a field in my primary key defined as identity generated always by default.
My next idea for this is to delete all the relevant records from the db and insert from the map but I dont like it.
Any ideas please? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Put something in DFHCOMMAREA to let you know which fields were populated from the database before sending the map. If the database record(s) are short enough, you could copy the actual data into DFHCOMMAREA; otherwise, use an indicator byte for each field on the map to denote that it is coming from the database. Check that byte before updating the database with that field. |
|
Back to top |
|
|
Ziko13
New User
Joined: 19 Jul 2018 Posts: 26 Location: Greece
|
|
|
|
yes...I will try the commarea solution |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3075 Location: NYC,USA
|
|
|
|
Don't FSET help to make that decision? If changed to 1 then insert else no. |
|
Back to top |
|
|
|