我導入了一個MySQL數據庫。所有成功導入的表格,但不包括函數。我可以執行SQL查詢的唯一方法是通過phpMyAdmin或PHP腳本(無SSH)。在phpMyAdmin中創建函數 - 錯誤:訪問被拒絕您需要此操作的超級權限
這裏的功能的示例導入:
DELIMITER ;;
/*!50003 DROP FUNCTION IF EXISTS `f_calc_gst` */;;
/*!50003 SET SESSION SQL_MODE=""*/;;
/*!50003 CREATE*/ /*!50020 DEFINER=`journal`@`%`*/ /*!50003 FUNCTION `f_calc_gst`(p_ht decimal(15,3), p_province varchar(2)) RETURNS varchar(255) CHARSET utf8
begin
declare res varchar(255);
declare v_gst decimal(15,3);
declare v_gst_formula varchar(255);
select GST, GST_formula
into v_gst, v_gst_formula
from taxes_periods
where NOW() between dt_debut and dt_fin
and id_province = p_province;
set v_gst_formula = replace(v_gst_formula, 'HT$', p_ht);
set v_gst_formula = replace(v_gst_formula, 'GST%', v_gst);
set res = concat('select round(', v_gst_formula, ',2) "gst"');
return res;
end */;;
如果我在phpMyAdmin粘貼此代碼,我得到這個錯誤:#1227 - 訪問被拒絕;你需要SUPER權限進行此操作
我試圖消除「/ !50003」和「 /」來取消對SQL,但我得到了同樣的錯誤消息。
我也試過不使用任何分隔符並刪除「DELIMITER ;;」而得到這個錯誤:
DROP FUNCTION IF EXISTS f_calc_gst SET SESSION SQL_MODE = "" CREATE DEFINER = `journal`@`%` FUNCTION `f_calc_gst` (
p_ht DECIMAL(15, 3) ,
p_province VARCHAR(2)
) RETURNS VARCHAR(255) CHARSET utf8 BEGIN declare res VARCHAR(255) ;
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET SESSION SQL_MODE=""
CREATE DEFINER=`journal`@`%` FUNCTION `f_calc_gst`(p_ht ' at line 2
也試過:
CREATE DEFINER=`journal`@`%` FUNCTION `f_calc_gst`(p_ht decimal(15,3), p_province varchar(2)) RETURNS varchar(255) CHARSET utf8
begin
declare res varchar(255);
declare v_gst decimal(15,3);
declare v_gst_formula varchar(255);
select GST, GST_formula
into v_gst, v_gst_formula
from taxes_periods
where NOW() between dt_debut and dt_fin
and id_province = p_province;
set v_gst_formula = replace(v_gst_formula, 'HT$', p_ht);
set v_gst_formula = replace(v_gst_formula, 'GST%', v_gst);
set res = concat('select round(', v_gst_formula, ',2) "gst"');
return res;
end//
導致:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3
是問題的SQL,phpMyAdmin的或與服務器?
可能重複http://stackoverflow.com/questions/8080681/store-procedures-in-phpmyadmin ) –
謝謝。在查看這篇文章之前,我沒有使用分隔符字段。我嘗試過,但我仍然有同樣的錯誤: #1227 - 訪問被拒絕;你需要這個操作的SUPER特權 – pec