insert value into field of another table on delete

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
lhardee
User
Posts: 36

insert value into field of another table on delete

Post by lhardee »

Hello,

I am working with 3 tables. One is called "interc" the second is called "redundancy" and the third is called "dual". Both redundancy and interc are similar tables with the exception of two fields in redundancy: the first is "higher_facility" and second is "keyvalue". The keyvalue field in redundancy is linked to a field in interc called "ID" The third table (dual) only has 1 field (D) with a value of D.
I would like to insert the letter "D" into the higher_facility field of redundancy when the user deletes a row in interc. Below is how I am trying to accomplish this task with no luck.

Inside intercinfo.php is the following code:

   function Row_Deleted(&$rs) {
   ew_ExecuteScalar("INSERT INTO redundancy(higher_facility) SELECT 'D' FROM dual WHERE NOT EXISTS(SELECT keyvalue FROM redundancy WHERE redundancy.keyvalue = ID)");
}

Any help would be appreciated.

lhardee


mobhar
User
Posts: 11905

Post by mobhar »

You should use "ew_Execute" instead of "ew_ExecuteScalar" if you want to execute the query without returning the value, such as DELETE, UPDATE, or INSERT INTO.

Use "ew_ExecuteScalar" only if you want to return the first column of the first row (usually SELECT query). Read "Some Global Functions" in the help file for further information and example.


Post Reply