MySQL writes call stored procedure using Navicat

Source: Internet
Author: User

Inside the navicat, find the function, right-click, new function, select the process, if there are parameters to fill in the function, if there is no direct click to complete

At the begin ... End writes the SQL statement to execute, such as the following stored procedure named Pro_data_bak:

begin/* back up data from Rd01_device_callback_data 2 days ago to rd01_device_callback_data_bak*/insert into Rd01_device_callback_data_ Bak (Id,imei,travelid,gps_time,receive_time,transmit_time,altitude,speed,latitude,longitude,course,pdop,satnum, Alarm_type0,alarm_name0,alarm_type1,alarm_name1,alarm_photo_linkurl,startup_time,shudown_time,is_used,create_ time,create_by,update_time,update_by) Selectid Id,imei imei,travelid travelid,gps_time gpsTime,receive_time Receivetime,transmit_time transmittime,altitude altitude,speed speed,latitudelatitude,longitude longitude,course Course,pdop pdop,satnum satnum,alarm_type0 ALARMTYPE0,ALARM_NAME0 alarmname0,alarm_type1 alarmType1,alarm_name1 Alarmname1,alarm_photo_linkurl alarmphotolinkurl,startup_time startuptime,shudown_time shudownTime,is_used isUsed, Create_time createtime,create_by createperson,update_time updatetime,update_by updatePersonFROMrd01_device_ Callback_datawhereto_days (now ())-To_days (create_time) > 1;/* delete rd01_device_callback_data 2 days ago Data */deletefromrd01_device_callback_datawhereto_days (now ())-To_days (create_time) > 1;/* back up data from Rd02_device_info 2 days ago to Rd02_device_ Info_bak*/insert into Rd02_device_info_bak (Id,message_id,message_property,imei,serial_number,message_split, message_body,media_id,check_code,create_time,create_person,update_time,update_person,is_used) SELECTid ID, Message_idmessageid,message_property Messageproperty,imei Imei,serial_numberserialnumber,message_split Messagesplit,message_body messagebody,media_id Meidiaid,check_code checkcode,create_time CreateTime,create_person Createperson,update_time updatetime,update_personupdateperson,is_used Isusedfromrd02_device_infowhereto_days (now ())-to_days (create_time) > 1;/* delete rd02_device_info 2 days ago Data */deletefromrd02_device_infowhereto_days (now ())-TO_ Days (Create_time) > 1;/* back up data from Rd_track_info 7 day to Rd_track_info_bak*/insert into Rd_track_info_bak (id,license_ Plate,device_id,address_name,altitude,speed,driving_direction,longitude,latitude,gps,back_time,road_name,road_ Code,road_leVel,road_speed_limit,back_seq_no,create_time,del_flag,alarm_type0,alarm_name0,alarm_type1,alarm_name1,alarm_ Photo_linkurl,gps_time) Selectid id,license_plate licenseplate,device_id deviceid,address_name addressName,altitude Altitude,speed speed,driving_direction drivingdirection,longitude longitude,latitude Latitude,gps gps,back_time Backtime,road_name Roadname,road_code roadcode,road_level roadlevel,road_speed_limit roadSpeedLimit,back_seq_no Backseqno,create_time Createtime,del_flag DELFLAG,ALARM_TYPE0 ALARMTYPE0,ALARM_NAME0 alarmName0,alarm_type1 Alarmtype1,alarm_name1 Alarmname1,alarm_photo_linkurl Alarmphotolinkurl,gps_time gpsTimeFROMrd_track_infoWHERETO_ Day (now ())-To_days (gps_time) > 7;/* delete rd_track_info 7 days ago Data */deletefromrd_track_infowhereto_days (now ())-To_days (gps_time) > 7; END

And then referencing it in XML.

<mapper namespace= "Com.ra.truck.mapper.DataBakMapper" ><select id= "Callprocedureofdatabak" >{call pro_ Data_bak ()}</select></mapper>

Calling this stored procedure via Java timed dispatch is OK.

MySQL writes call stored procedure using Navicat

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.