First of all, it is necessary to execute the delimiter, the proposed use//, that is, before the beginning of the stored procedure definition delimiter//, after the end Plus//, and finally add delimiter; The specific reason @ Reference Article 1 wrote very clearly, no longer repeat.
Refer to the example in article 1:
Delimiter//;--change MySQL delimiter to: "//" Drop procedure if existsPr_stat_agent// --Call pr_stat_agent (' 2008-07-17 ', ' 2008-07-18 ') Create procedurepr_stat_agent (pi_date_from date, pi_date_to date)begin --Check Input if(Pi_date_from is NULL) Then SetPi_date_from= current_date(); End if; if(pi_date_to is NULL) Then SetPi_date_to=Pi_date_from; End if; SetPi_date_to=Date_add (Pi_date_from, Interval1 Day); --Stat SelectAgentCount(*) asCNT fromApache_logwhereRequest_time>=Pi_date_from andRequest_time<pi_date_toGroup byAgentOrder byCntdesc; End;//delimiter;// --change back to the default MySQL delimiter: ";"
View Code
MySQL stored procedures