Trigger to Prevent Negative Stock
Create a trigger that rejects any update that would make Stock.qty negative.
Table schema
Stock(product VARCHAR(20) PRIMARY KEY, qty INT)Sample data
Row (Pen, 5). UPDATE Stock SET qty = qty - 8 WHERE product = 'Pen'; must fail.
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.