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?
Joined: 06 Jun 2008 Posts: 8567 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.