Question

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

Was it helpful?

Solution

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;
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top