MySQL Forums
Forum List  »  Triggers

Help with a trigger to change field to a negative value
Posted by: mark paterson
Date: May 11, 2021 08:29AM

I have a database called check_register that has one table called transactions. The transactions table has the following columns:

transID int (auto increment) primary key
amount int
withdraw varchar [values are either yes or no]


is there a way to write a trigger that will look to see if the withdraw field = yes then change the amount value to a negative value?



for example, a record entered with the following values:

transID: 1
amount: 20.00
withdraw: yes

the trigger would replace 20.00 with -20.00



Thank you in advance. I'm trying to teach myself ways to have the database help with data manipulation,

Options: ReplyQuote


Subject
Views
Written By
Posted
Help with a trigger to change field to a negative value
150
May 11, 2021 08:29AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.