写一个带CREATE DEFINER = CURRENT_USER PROCEDURE 的mysql存储过程
时间: 2023-04-09 21:03:55 浏览: 216
我可以回答这个问题。下面是一个带CREATE DEFINER = CURRENT_USER PROCEDURE的mysql存储过程的示例:
CREATE DEFINER = CURRENT_USER PROCEDURE my_procedure_name()
BEGIN
-- 在这里编写存储过程的代码
END;
请注意,这只是一个示例,实际的存储过程需要根据具体的需求进行编写。
相关问题
DELIMITER $$ CREATE /*[DEFINER = { user | CURRENT_USER }]*/ PROCEDURE `qy_task`.`peopletask`(IN job VARCHAR(200),IN seriesid VARCHAR(200),IN classid VARCHAR(200),IN prodid VARCHAR(200),IN cycleid VARCHAR(200) ) /*LANGUAGE SQL | [NOT] DETERMINISTIC | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } | SQL SECURITY { DEFINER | INVOKER } | COMMENT 'string'*/ BEGIN #把表围绕id创建一边然后再关联输出数据 CREATE TEMPORARY TABLE IF NOT EXISTS taskpeople SELECT gst.job_number, '' AS AREA, SUM(gst.amount) AS amount, SUM(gst.weight) AS weight, SUM(gst.area) AS AREA, SUM(qsc.weight) AS taskweight, SUM(qsc.weight)/SUM(gst.weight) AS percent FROM qy_goal_salesman_task gst INNER JOIN qy_goal_area_task gat ON gat.id =gst.area_task_id INNER JOIN qy_goal_company_task gct ON gct.id=gst.company_task_id INNER JOIN qy_goal_sale_cycle_config scc ON scc.id=gct.cycle_id INNER JOIN qy_goal_prod_config gpc ON gpc.id=gst.prod_id AND gpc.cycle_id=scc.id INNER JOIN qy_goal_prod_series_config psc ON psc.id=gpc.prod_series_id AND psc.cycle_id=scc.id INNER JOIN qy_goal_prod_classify_config pcc ON pcc.id = psc.prod_type_id AND pcc.cycle_id=scc.id INNER JOIN qy_goal_client_task_detail ctd ON gst.salesman_id=ctd.id INNER JOIN qingyuan.sys_circle sc ON sc.id=ctd.client_id INNER JOIN crm_c_duty_saler duty ON duty.c_id=sc.id INNER JOIN qyng_sys_user qsu ON qsu.id= duty.User_Id LEFT JOIN qy_sys_countydetail qsc ON qsc.proname=Pro_Name WHERE scc.id=cycleid AND qsc.CreateTime>=(SELECT start_date FROM qy_goal_sale_cycle_config WHERE id=cycleid) AND qsc.CreateTime<=(SELECT end_date FROM qy_goal_sale_cycle_config WHERE id=cycleid) AND qsc.GetTime=(SELECT MAX(GetTime) FROM qy_sys_countydetail) AND gpc.id=prodid AND pcc.id=classid AND psc.id=seriesid AND gst.job_number=job GROUP BY gst.job_number; #将临时表进行数据转换 UPDATE taskpeople SET job_number= ff.User_Name FROM taskpeople e INNER JOIN qyqx.qy_staff ff ON e.job_number=ff.uid; #查出真正的表 SELECT * FROM taskpeople; #删除临时表 DROP TEMPORARY TABLE taskpeople; END$$ DELIMITER ;这段mysql存储过程哪里出现了语法错误
这段 MySQL 存储过程中出现了语法错误,具体来说是在以下这行代码:
```
GROUP BY gst.job_number;
```
末尾多了一个分号,应该改为:
```
GROUP BY gst.job_number;
```
mysql存储过程语法
MySQL存储过程语法如下:
```
CREATE [DEFINER = { user | CURRENT_USER }] PROCEDURE sp_name ([proc_parameter[,...]])
[characteristic ...] routine_body
proc_parameter:
[ IN | OUT | INOUT ] param_name type
type:
Any valid MySQL data type
characteristic:
COMMENT 'string'
| LANGUAGE SQL
| [NOT] DETERMINISTIC
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
routine_body:
Valid SQL procedure statement
```
其中,`DEFINER` 可选,是指定存储过程的创建者,默认为当前用户。`sp_name` 是存储过程的名称,`proc_parameter` 是存储过程的参数,可以是输入参数(`IN`)、输出参数(`OUT`)或者输入输出参数(`INOUT`)。`type` 是参数的数据类型,可以是 MySQL 的任何数据类型。
`characteristic` 是存储过程的特性,可以是注释、语言、是否确定性、是否包含 SQL 语句、SQL 安全性等。
`routine_body` 是存储过程的主体,是有效的 SQL 存储过程语句。
阅读全文