Try this fix:
FETCH NEXT FROM xy INTO @delano
Or redesign the triggers to avoid the cursors. (Make sure that the triggers work in case of multiple inserted and deleted rows).
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have 2 trigger, one is for insert and another for delete..
but when i run delete query, an error occurred : A cursor with the name 'x' does not exist.
while x is insert trigger cursor name !
here is trigger for deleted
Can anyone explain for me, thanks
Note that in the DELETE trigger, the FETCH statement is missing at the end of the loop, so if you delete more then one row, the trigger will run forever.
But it is complete insanity to have a cursor here. I don't know your details, but this is my guess how the DELETE trigger should look like:
CREATE TRIGGER dbo.hyudon ON dbo.dothang AS
UPDATE stock
SET souluongton += d.sl
FROM stock st
JOIN (SELECT ordered, SUM(sl) AS sl
FROM deleted
GROUP BY ordered) AS d ON d.orderd = st.id