Hi I need a help in the below issue. I have table where data being updated every minute. I have a trigger set on this table.
CREATE DEFINER=`root`@`localhost` TRIGGER `gsdatatabs_AFTER_UPDATE` AFTER UPDATE ON
`gsdatatabs` FOR EACH ROW BEGIN
IF NEW.CAMARILLA = 'B' or NEW.CAMARILLA = 'S' then
UPDATE gsdatatabs SET ALERT = NEW.LTP;
END IF;
END
Below is my table structure
Columns:
SCRIP varchar(45)
LTP float
OHL varchar(45)
ORB15 varchar(45)
ORB30 varchar(45)
PRB varchar(45)
CAMARILLA varchar(45)
ALERT float
I am trying to update ALERT column with value from LTP when the CAMARILLA value is 'B' or 'S'. In the backend the data for CAMARILLA column gets updated every minute.
Currently while updating in the backend getting error.
Error: Can't update table 'gsdatatabs' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
at Packet.asError (C:\Users\sprasadswain\Documents\googleSheet\AutoTrader\Server\node_modules\mysql2\lib\packets\packet.js:722:17)
at Query.execute (C:\Users\sprasadswain\Documents\googleSheet\AutoTrader\Server\node_modules\mysql2\lib\commands\command.js:28:26)
at Connection.handlePacket (C:\Users\sprasadswain\Documents\googleSheet\AutoTrader\Server\node_modules\mysql2\lib\connection.js:456:32)
at PacketParser.onPacket (C:\Users\sprasadswain\Documents\googleSheet\AutoTrader\Server\node_modules\mysql2\lib\connection.js:85:12)
at PacketParser.executeStart (C:\Users\sprasadswain\Documents\googleSheet\AutoTrader\Server\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket.<anonymous> (C:\Users\sprasadswain\Documents\googleSheet\AutoTrader\Server\node_modules\mysql2\lib\connection.js:92:25)
at Socket.emit (events.js:315:20)
Kindly guide