1

I'm trying to catch an insert on a table and do update instead in some specific cases. How do i go about that? I'm trying to put this in insert method in CustTable table, but i'm not sure where to put the code.

Any ideas?

Thanx, Ivan

Ivan Z.
  • 23
  • 1
  • 5

1 Answers1

2

It is bad practice to do updates instead of inserts in the insert method!
Consider the effect on data imports etc.

Consider moving the logic to the CustTable form instead.

This is the way to do it anyway (in the table insert method):

 void insert()
 {
     CustTable t;
     ttsbegin;
     if (<condition>)
     {              
         select forupdate t where ...;
         t.Name = this.Name; // Saving name only
         t.doUpdate();
     }
     else
         super() //does the doInsert()
     ttscommit;
 }
Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Thanx! I'll try this code.I am trying to do it in AIF web service create method. I want it to update nly in case where customer which comes from some outer system exists. – Ivan Z. Jan 17 '11 at 14:42