1, run on phpMyAdmin, for inserting data, associating product with freight chart
1 /*To define a stored procedure decomposition character*/2Delimiter//3 DROP PROCEDURE IF EXISTSDoshipping//4 CREATE PROCEDUREdoshipping ()5 BEGIN6 /*declaring Variables*/7 DECLARENo_more_recordINT DEFAULT 0;8 DECLAREIINT;9 DECLAREEntityIdBIGINT(Ten);Ten /*creating a cursor variable*/ One DECLARECur_recordCURSOR for SELECTentity_id fromCatalog_product_entityORDER byentity_idDESC; A DECLARE CONTINUEHANDLER for notFOUNDSETNo_more_record=1; - - OPENCur_record; the /*Fetching cursor Variables*/ - FETCHCur_record intoEntityId; - /*loop to get each product ID*/ - whileNo_more_record!=1 Do + SETI=0; - /*cyclic correlation for each product associated freight*/ + whileI<4 Do A CaseI at when 0 Then - INSERT intodirectory_country_shipping (Group_product_id,ship_method,ship_cost,ship_eachadd,ship_listcountry, -Delivery_time,show_order,created_time,update_time)VALUES(EntityId,' Free','0.00','0.00','All Country','15-30','0', now (), now ()); - when 1 Then - INSERT intoyo_directory_country_shipping (Group_product_id,ship_method,ship_cost,ship_eachadd,ship_listcountry, -Delivery_time,show_order,created_time,update_time)VALUES(EntityId,' Standard','10.00','2.00','All Country','10-15','1', now (), now ()); in when 2 Then - INSERT intoyo_directory_country_shipping (Group_product_id,ship_method,ship_cost,ship_eachadd,ship_listcountry, toDelivery_time,show_order,created_time,update_time)VALUES(EntityId,'Economical','9.00','3.00','All Country','5-10','2', now (), now ()); + ELSE - INSERT intoyo_directory_country_shipping (Group_product_id,ship_method,ship_cost,ship_eachadd,ship_listcountry, theDelivery_time,show_order,created_time,update_time)VALUES(EntityId,'Speedy','8.00','2.00','All Country','3-5','3', now (), now ()); * END Case; $ SETI=I+1;Panax Notoginseng END while; - FETCHCur_record intoEntityId; the END while; + /*Close cursor Variable*/ A CLOSECur_record; the END;// +delimiter;
Write a simple stored procedure instance note