lundi 25 juillet 2016

SQL Check if an update doesn't go below a certain level

I have a stock table (MySQL) which has item and quantity as the two fields.

When an update is performed for example:

UPDATE stock SET Quantity = (Quantity - ?) WHERE ItemName = ?

How can I perform a check and then send an error message to deny the update if the Quantity - Value is < 0?

Aucun commentaire:

Enregistrer un commentaire