CREATE PROCEDURE in mySQL -


i'm creating mysql procedure in phpmyadmin , keeps throwing error: #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '' @ line 18

i've tried code below , without delimiter, without avail. can point what's wrong code? thank you!

delimiter \\ create procedure orderbooks(in store varchar(10), in title varchar(50)) begin     declare order_num varchar(100);      declare tod date;     select @ordered_qty := qty customer_sales customer_sales.store_id = store , customer_sales.title_id = title;     select @in_stock := qty store_inventories store_inventories.stor_id=store , store_inventories.title_id = title;     select @threshold := minstock store_inventories store_inventories.stor_id=store , store_inventories.title_id = title;     set order_num = concat(store, title);     set tod = getdate();     if (@ordered_qty < (@in_stock - @threshold)) update store_inventories set qty = (@in_stock - @ordered_qty) store_inventories.stor_id = store , store_inventories.title_id = title;     else         insert pending_orders(stor_id, ord_num, title_id, qty, date, fulfilled) values(store, order_num, title, (@ordered_qty + @threshold), tod ,1);         insert sales values(store, order_num, tod);         insert salesdetail values(store, order_num, title , (@ordered_qty + @threshold),0);         update pending_orders set fulfilled=0 pending_orders.stor_id = store , pending_orders.title_id = title;         update store_inventories set qty = (@threshold + @in_stock) store_inventories.stor_id = store , store_inventories.title_id= title;         delete pending_orders pending_orders.stor_id = store , pending_orders.title_id = title; end\\  delimiter ; 

try one:

create procedure orderbooks(in store varchar(10), in title varchar(50)) begin     declare order_num varchar(100);      declare tod date;     select @ordered_qty := qty customer_sales customer_sales.store_id = store , customer_sales.title_id = title;     select @in_stock := qty store_inventories store_inventories.stor_id=store , store_inventories.title_id = title;     select @threshold := minstock store_inventories store_inventories.stor_id=store , store_inventories.title_id = title;     set order_num = concat(store, title);     set tod = getdate();     if (@ordered_qty < (@in_stock - @threshold)) update store_inventories set qty = (@in_stock - @ordered_qty) store_inventories.stor_id = store , store_inventories.title_id = title;     else         insert pending_orders(stor_id, ord_num, title_id, qty, date, fulfilled) values(store, order_num, title, (@ordered_qty + @threshold), tod ,1);         insert sales values(store, order_num, tod);         insert salesdetail values(store, order_num, title , (@ordered_qty + @threshold),0);         update pending_orders set fulfilled=0 pending_orders.stor_id = store , pending_orders.title_id = title;         update store_inventories set qty = (@threshold + @in_stock) store_inventories.stor_id = store , store_inventories.title_id= title;         delete pending_orders pending_orders.stor_id = store , pending_orders.title_id = title;     end if end 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -