Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][SQL] Próba utworzenia funkcji w PMA powoduje błąd #1064
maryl16
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 16.02.2015
Skąd: Tczew

Ostrzeżenie: (0%)
-----


Witam,
mam problem z utworzeniem funkcji w PMA:

  1. DROP FUNCTION IF EXISTS `ss6_pl_calculateProductPriceForUser`$$
  2. CREATE DEFINER=`samal_14451501`@`%` FUNCTION `ss6_pl_calculateProductPriceForUser`(piUser INT, piProduct INT, piPromotions INT) RETURNS double
  3. READS SQL DATA
  4. 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


, 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
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 10:02