Navicat Premium Create a MySQL stored procedure

Source: Internet
Author: User
Tags prepare

1. Use Navicat Premium to open the Create Function Wizard, Operation: Connection name--database--function--new function

2, the selection process-input stored procedure parameters-complete (This step can not fill in parameters, write stored procedure Code when setting parameters)

3, as required to complete the stored procedure Code writing

1 BEGIN2     DECLARET_errorINTEGER DEFAULT 0; 3     DECLARE CONTINUEHANDLER forSQLEXCEPTIONSETT_error=1;4 # Ensure data consistency open transactions5STARTTRANSACTION;6 # Get the time node to synchronize data (first day 3 months ago)7# That's the current date2018- --Ten  @upmonthDate2018-Geneva- on8         SET @upmonth=Date_add (Curdate ()-  Day(Curdate ())+ 1, INTERVAL- 3 MONTH);9 # Migrating data StatementsTen         SET @sqlstr=CONCAT ('INSERT into Fd_aseet_record_back_3_6 One SELECT * from Fd_asset_record WHERE type in (3, 6) and Calendar_date <?'); A # Delete Data statement -         SET @delsqlstr=CONCAT ('DELETE from Fd_asset_record WHERE type in (3, 6) and Calendar_date <?'); - #执行数据迁移 the         PREPARE_fddatamt from @sqlstr; -         EXECUTE_fddatamt USING@upmonth; -         deallocate PREPARE_fddatamt; - #执行迁移后的数据删除 +         PREPARE_fddatadel from @delsqlstr; -         EXECUTE_fddatadel USING@upmonth; +         deallocate PREPARE_fddatadel; A     IFT_error= 1  Then   at      ROLLBACK; #语句异常-rolling back -     ELSE   -      COMMIT; #提交事务 -     END IF;  - END

4. Save--Enter the name of the stored procedure--determine

5. Select the stored procedure name--run function--View results

Navicat Premium Create MySQL stored procedure

Related Article

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.