Hi,
i got tis trigger

CREATE PROCEDURE updateG
AFTER INSERT
ON gnojidba
FOR EACH ROW BEGIN
DECLARE box int;
SELECT quantity
INTO box
FROM stock
WHERE name = NEW.name;
IF (box >= NEW.Qty_value)
THEN
UPDATE stock
SET quantity = (quantity-NEW.Qty_value)
WHERE name = NEW.name;
ELSE
UPDATE 'Error!' SET x=1;
END IF;
END;

Problem: after user input quantity is changed in both tables and thats ok, but if user enters quantity that is greater than quantity in stock table, that greater value is inserted and stock quantity stays the same. I try also with raise error..., call, signal...etc.
Is it possible to alert user somehow on such a event?
tnx
Igor

Recommended Answers

All 2 Replies

Here's an SO thread with an example of how to use signal (if available in your version of MySql).

until my host update to 5.5 ill use this

....
   WHERE something= NEW.something;
        ELSE
            CALL nonexistingprocedure;
        END IF;
END;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.