I am writing a trigger after insert event on a table. This is the table
CREATE TABLE `orderitem` (
`orderItemId` INT(11) NOT NULL AUTO_INCREMENT,
`orderItemQuantity` INT(11) NULL DEFAULT NULL,
`stockId` INT(11) NULL DEFAULT NULL,
`rate` DOUBLE NULL DEFAULT NULL,
`orderId` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`orderItemId`)
)
Inside the trigger I need the values inserted for the current row(not only the id) inside the trigger. In T-SQL we can use the inserted table but in MySQL I could not find anything like that. How can I get those values? Thanks in advance.
You could use OLD. or NEW. since this trigger is fired after the insert both values are the same. You can access all properties of the interred row (if it is a row level trigger) by using:
NEW.orderItemID
NEW.rate
etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With