mysql trigger problem
覃斌
覃斌 2018-08-07 10:02:20
0
2
1232

After looking at the triggers in the database, I thought, if the quantity inserted into an order table is greater than the product table, then the product table should be a negative number and should be restricted. But when I use before to limit, it cannot be executed. Can anyone help me see what is wrong with this string of code?

create trigger tg1

before insert on ord

for each row

begin

if new.o_num > goods.g_num then

set new.o_num = goods.g_num

end if;

update goods set g_num = g_num - new.o_num where gid = new.gid;

end$

覃斌
覃斌

reply all(2)
ll

if new.o_num > goods.g_num then

set new.o_num = goods.g_num

When the quantity of DD is greater than the inventory quantity, you make the quantity of DD equal to the quantity of inventory You can use phpmyadmin to create triggers

ll

You don’t need a trigger to do this. Limit the quantity you buy before buying.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!