MySQL custom functions and procedural considerations

Source: Internet
Author: User

1 BEGIN2 #Routine body goes here ...3 /*4 Update Szzx_goods_common set gc_id=i where Gc_name= (SELECT gc_name from Szzx_goods_class where gc_id=i);5 */6  DECLAREI,goodsidint( One);7  DeclareGoodsname,imgVarCHAR( $);8  SetI=104;9   whileI<1815 DoTen SELECTimage_url,goods_id intoImg,goodsid fromGoods_imagewhereimage_id=i; One#SELECTgoods_id intoGoodsid fromEcm_goods_imagewhereimgage_id=i; A SELECTGoods_name intoGoodsname fromEcm_goodswheregoods_id=Goodsid; - Selectgoods_id intoGoodsid fromSzzx_goodswhereGoods_name=Goodsname; - INSERT  intoSzzx_goods_images (Goods_commonid,store_id,goods_image,goods_image_sort)VALUES(Goodsid,1Img1); the SetI=I+1; -  - End  while; -     RETURN 0; + ENd

1. When using variables, define the variables and then assign them to the bottom. Multiple variable types are consistent and can be formatted with declare variable name 1, variable name 2.

2, in a function or procedure to assign a value to a variable with a SELECT statement, the format should be: Select field 1, field 2 into variable 1, variable 2 from table name format

MySQL custom functions and procedural considerations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.