Programmers learn & share
0 votes
83 views

Problem :

 I am currently facing an issue with MySQL!

I am the cPanel user, and I am looking for the solution on my issue. It seems this is more specific than other people with the same error codes issues.

Please find below my code for the reference:

DELIMITER $$--
-- Functions
--
CREATE DEFINER =  `root`@`localhost` FUNCTION  `fnc_calcWalkedDistance` (
`steamid64` BIGINT UNSIGNED
) RETURNS INT( 10 ) UNSIGNEDNO SQL BEGIN DECLARE finished INTEGER DEFAULT 0;
DECLARE distance INTEGER DEFAULT 0;
DECLARE x1, x2, z1, z2 FLOAT;
DECLARE curs CURSOR FOR SELECT x, z
FROM log_positions
WHERE  `steamid` = steamid64
ORDER BY  `timestamp` DESC ;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished =1;
OPEN curs;
FETCH curs INTO x1, z1;
SET x2 = x1;
SET z2 = z1;
calculate : LOOPFETCH curs INTO x1, z1;
IF finished =1 THEN LEAVE calculate;
END IF ;
SET distance = distance + SQRT( POW( x2 - x1, 2 ) + POW( z2 - z1, 2 ) ) ;
-- SET distance = distance + 1;
SET x2 = x1;
SET z2 = z1;
END LOOP calculate;
CLOSE curs;
RETURN distance;
END$$

Following is the error from the code:

MySQL said: Documentation

#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation

by (6.9k points)   | 83 views

1 Answer

0 votes

Solution :

It clearly says that you do not have the required privileges to create the trigger with root@localhost user.

Please remove the definer from the trigger command as shown below:

CREATE DEFINER = root@localhost FUNCTION fnc_calcWalkedDistance

by (36.1k points)  
2,245 questions
2,807 answers
60 comments
241 users