MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

update table issue with trigger

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
blitz2
Beginner


Joined: 23 Jan 2007
Posts: 84
Topics: 14

PostPosted: Wed Jan 24, 2007 9:47 am    Post subject: update table issue with trigger Reply with quote

CICS screen has got fields for names (maximum 6 in number with each 5 bytes in length; no duplicates), say,

ABRAH JOHNY JOSHU ROSAK SILLY

They are stored in a DB2 table. The names are part of the primary key. The table has triggers defined for Insert, Delete and Updates to the table. Requirement is such that when the entries are made as say below,

JOYCE JOHNY BILLY ROSAK SILLY SIVAN

Update trigger should be triggered twice (ABRAH<->JOYCE, JOSHU<->BILLY) and the Insert trigger once (SIVAN)

We coded a straight-forward logic to select the old values from the table and do an update with new values .. And extra entries from the screen being inserted .. or if DB2 table contains additional entries than that received from screen, then delete.

Problem happens when circular references are entered on the screen, like,
JOHNY ABRAH ROSAK SILLY BILLY SIVAN

When we try to update ABRAH with JOHNY, it fails with a -803(duplicate). Next same thing happens for JOHNY<->ABRAH, JOSHU<->ROSAK,ROSAK<->SILLY) ... SILLY<->BILLY update and SIVAN insert goes through. Currently, we perform this process 6 times so that all values get updated properly.

Still the problem is that for an update on screen like,
JOHNY ABRAH JOSHU ROSAK SILLY

it never works. Business is adamant that they want ABRAH<->JOHNY and JOHNY<->ABRAH to trigger the update trigger. On the development front, we have a headache now. Because it's always going to get a -803 no matter what you do.

I hope that I have been able to explain the problem properly. Anybody faced anything like this before. Any suggestions?

the triggers insert rows in another table from which an audit report with old and new values are generated. So that is why we are after the UPDATE command rather than a DELETE and then an INSERT
________
no2 vaporizer


Last edited by blitz2 on Wed Feb 02, 2011 3:08 am; edited 1 time in total
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Jan 24, 2007 10:16 am    Post subject: Reply with quote

blitz2,

I think you are complicating by performing multiple updates/insert/delete sequence. Updating a primary key is only possible if you have a stand alone table.

1. Read the screen entries
2. Check if the row exists
3. Sort both the table entry and screen entries as the column sequence ascending.

Code:

  1     2     3     4     5    6
===== ===== ===== ===== ===== ===== 
ABRAH JOHNY JOSHU ROSAK SILLY

Code:

  1     2     3     4     5    6
===== ===== ===== ===== ===== ===== 

JOYCE JOHNY BILLY ROSAK SILLY SIVAN


4.Now compare each db2 column entry to screen entry and populate the host variable with the update values.

5. If changes are made
a) Delete the row
b) insert the new row.

By doing like you will never encounter -803 errors

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
blitz2
Beginner


Joined: 23 Jan 2007
Posts: 84
Topics: 14

PostPosted: Thu Jan 25, 2007 3:59 am    Post subject: Reply with quote

Kolusu, thanks for the response.
________
volcano vaporizers
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group