mam problem z utworzeniem funkcji w PMA:
DROP FUNCTION IF EXISTS `ss6_pl_calculateProductPriceForUser`$$ CREATE DEFINER=`samal_14451501`@`%` FUNCTION `ss6_pl_calculateProductPriceForUser`(piUser INT, piProduct INT, piPromotions INT) RETURNS double READS SQL DATA BEGIN DECLARE xiActiveDiscount INT; DECLARE xfPrice DOUBLE; DECLARE xfUserMultiply DOUBLE; DECLARE xfDiscount DOUBLE; DECLARE xfProductMultiply DOUBLE; DECLARE xfMultiply DOUBLE; SELECT `iActiveDiscount`, `fPrice` FROM `ss6_pl_products` WHERE `iProduct` = piProduct INTO xiActiveDiscount, xfPrice; IF ((piUser IS NOT NULL) AND (xiActiveDiscount > 0) ) THEN SELECT MAX(`fDiscount`) FROM `ss6_users_groups` INNER JOIN `ss6_users_to_groups` USING(`iGroup`) WHERE `iUser` = piUser INTO xfDiscount; IF (xfDiscount IS NULL) THEN SET xfDiscount = 0; END IF; SET xfUserMultiply = 1 - xfDiscount; SELECT MIN(`fMultiply`) FROM `ss6_pl_products_discounts` INNER JOIN (`ss6_users_groups` INNER JOIN `ss6_users_to_groups` USING (`iGroup`) ) USING (`iGroup`) WHERE ((`iUser` = piUser) AND (`iProduct` = piProduct) ) INTO xfProductMultiply; IF (xfProductMultiply IS NULL) THEN SET xfProductMultiply = 1; END IF; IF (piPromotions > 0) THEN RETURN xfPrice * xfUserMultiply * xfProductMultiply; ELSE IF (xfUserMultiply > xfProductMultiply) THEN SET xfMultiply = xfProductMultiply; ELSE SET xfMultiply = xfUserMultiply; END IF; RETURN xfPrice * xfMultiply; END IF; ELSE RETURN xfPrice; END IF; END$$
Przy próbie wykonania zapytaniawyświetla się następujący komuniakt
Kod
#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 '$$
CREATE DEFINER=`samal_14451501`@`%` FUNCTION `ss6_pl_calculateProductPriceFo' at line 1
CREATE DEFINER=`samal_14451501`@`%` FUNCTION `ss6_pl_calculateProductPriceFo' at line 1
, zaś po "wyklikaniu" w PMA
Kod
MySQL zwrócił komunikat #1064 - You have an erroe in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use neat "at line 1"
Proszę o pomoc. Ponieważ przenoszę bazę z hostingu na hosting i reszta się zaimportowała tylko z tym mam problem.
Pozdrawiam
-maryl16