DELIMITER //
    CREATE FUNCTION F_offshorePrice1(topsbwynum INTEGER, hulsbwynum INTEGER,sbwynum INTEGER, adjprice FLOAT(11,2),
    price FLOAT(11,2), estprice FLOAT(11,2), pricehulint FLOAT(11,2), pricetopint FLOAT(11,2), pricehulcons FLOAT(11,2),
    pricetop FLOAT(11,2),priceint FLOAT(11,2),pricetht FLOAT(11,2) )
        RETURNS float(20,2)
        NOT DETERMINISTIC
        CONTAINS SQL
       SQL SECURITY DEFINER
    BEGIN

     DECLARE FinalPrice VARCHAR(20);
     DECLARE err VARCHAR(20);

     DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET err = 1;



    IF(sbwynum > 0 AND hulsbwynum > 0 and sbwynum != hulsbwynum AND (topsbwynum = sbwynum OR topsbwynum < 1 or topsbwynum IS NULL)) THEN
      IF (pricetopint > 0) THEN
         SET FinalPrice = pricetopint;
       ELSEIF(price > 0)THEN
         SET FinalPrice = price - pricehulcons;
       ELSEIF(estprice > 0)THEN
         SET FinalPrice = estprice - pricehulcons;
        END IF;

    END IF;



    IF(sbwynum > 0 AND topsbwynum > 0 and sbwynum != topsbwynum AND (hulsbwynum = sbwynum OR hulsbwynum < 1 or hulsbwynum IS NULL)) THEN
    IF(pricehulint > 0)THEN
       SET FinalPrice = pricehulint;
     ELSEIF(price > 0)THEN
      SET FinalPrice = price - pricetop;
    ELSEIF(s.estprice > 0)THEN
      SET FinalPrice = estprice - pricetop;
    END IF;

    END IF;


    IF(sbwynum > 0 AND topsbwynum != hulsbwynum AND hulsbwynum != sbwynum AND topsbwynum != sbwynum AND topsbwynum > 0 and hulsbwynum > 0 )THEN
    IF(priceint > 0)THEN
      SET FinalPrice = priceint;
    ELSEIF(price > 0)THEN
      SET FinalPrice = price - (pricetop + pricehulcons);
    ELSEIF(estprice > 0)THEN
      SET FinalPrice = estprice - (pricetop + pricehulcons);
    END IF;

    END IF;


    IF(sbwynum > 0 AND topsbwynum = hulsbwynum AND sbwynum != hulsbwynum AND hulsbwynum > 0 )THEN
    IF(priceint > 0)THEN
      SET FinalPrice = priceint;
    ELSEIF(price > 0)THEN
      SET FinalPrice = price - pricetht;
    ELSEIF(estprice > 0)THEN
      SET FinalPrice = estprice - pricetht;
    END IF;

    END IF;


    IF(sbwynum > 0)THEN
    IF(FinalPrice > 0)THEN
      RETURN FinalPrice;
    ELSEIF(adjprice > 0)THEN
       RETURN adjprice;
    ELSEIF(price > 0)THEN
       RETURN price;
    ELSEIF(estprice > 0)THEN
       RETURN estprice;
    ELSE
       RETURN 0;
    END IF;
    ELSE
      RETURN 0;
    END IF;


    END //

    DELIMITER ;


错误:=

错误
您的SQL查询中似乎有一个错误。下面的MySQL服务器错误输出(如果有的话)也可能有助于您诊断问题

错误:@的未公开报价
STR:SQL: CREATE FUNCTION F_offshorePrice1(topsbwynum INTEGER,hulsbwynum INTEGER,sbwynum INTEGER,adjprice FLOAT(11,2),
price FLOAT(11,2),estprice FLOAT(11,2),pricehulint FLOAT(11,2),pricetopint FLOAT(11,2),pricehulcons FLOAT(11,2),
pricetop FLOAT(11,2),priceint FLOAT(11,2),pricetht FLOAT(11,2))
返回float(20,2)
不确定的
包含SQL
SQL安全定义器
评论:“此功能将用于海上定价系统,表示邮件ID:= 40516”
开始

DECLARE FinalPrice VARCHAR(20);
声明err VARCHAR(20);

SQLEXCEPTION SET的DECLARE继续处理程序err = 1;

IF(sbwynum> 0 AND hulsbwynum> 0和sbwynum!= hulsbwynum AND(topsbwynum = sbwynum或topsbwynum 如果(pricetopint> 0)然后
SET FinalPrice = pricetopint;
ELSEIF(价格> 0)
SET FinalPrice =价格-pricehulcons;
ELSEIF(价格> 0)
SET FinalPrice = estprice-pricehulcons;
万一;

万一;

IF(sbwynum> 0 AND topsbwynum> 0和sbwynum!= topsbwynum AND(hulsbwynum = sbwynum或hulsbwynum 如果(pricehulint> 0)
SET FinalPrice = pricehulint;
ELSEIF(价格> 0)
SET FinalPrice =价格-pricetop;
ELSEIF(最低价格> 0)
SET FinalPrice = estprice-pricetop;
万一;

万一;

IF(sbwynum> 0 AND topsbwynum!= hulsbwynum和hulsbwynum!= sbwynum AND topsbwynum!= sbwynum AND topsbwynum> 0和hulsbwynum> 0)
如果(priceint> 0)
SET FinalPrice = priceint;
ELSEIF(价格> 0)
SET FinalPrice =价格-(pricetop + pricehulcons);
ELSEIF(价格> 0)
SET FinalPrice = estprice-(pricetop + pricehulcons);
万一;

万一;

IF(sbwynum> 0 AND topsbwynum = hulsbwynum AND sbwynum!= hulsbwynum AND hulsbwynum> 0)
如果(priceint> 0)
SET FinalPrice = priceint;
ELSEIF(价格> 0)
SET FinalPrice =价格-pricetht;
ELSEIF(价格> 0)
SET FinalPrice = estprice-pricetht;
万一;

万一;

如果(sbwynum> 0)
如果(最终价格> 0)
返回FinalPrice;
ELSEIF(价格> 0)
返回价格
ELSEIF(价格> 0)
返回价格;
ELSEIF(价格> 0)
返回价格
其他
返回0;
万一;
其他
返回0;
万一;

结束 //

定界符;

SQL查询:

CREATE FUNCTION`F_offshorePrice1(topsbwynum INTEGER,hulsbwynum INTEGER,sbwynum INTEGER,adjprice FLOAT(11,2),price FLOAT(11,2),estprice FLOAT(11,2),pricehulint FLOAT(11,2),pricetopint FLOAT(11) ,2),pricehulcons FLOAT(11,2),pricetop FLOAT(11,2),priceint FLOAT(11,2),pricetht FLOAT(11,2))返回float(20,2)不确定的内容SQL SQL安全定义注释“此功能将用于海上定价系统,请参阅邮件ID:= 40516”开始声明FinalPrice VARCHAR(20);声明err VARCHAR(20); SQLEXCEPTION SET的DECLARE继续处理程序err = 1; IF(sbwynum> 0 AND hulsbwynum> 0且sbwynum!= hulsbwynum AND(topsbwynum = sbwynum或topsbwynum 0)THEN SET FinalPrice = pricetopint; ELSEIF(price> 0)THEN SET FinalPrice = price-pricehulcons; ELSEIF(estprice> 0)THEN SET FinalPrice = estprice-pricehulcons;万一;万一; IF(sbwynum> 0 AND topsbwynum> 0和sbwynum!= topsbwynum AND(hulsbwynum = sbwynum或hulsbwynum 0)THEN SET FinalPrice = pricehulint; ELSEIF(price> 0)THEN SET FinalPrice = price-pricetop; ELSEIF(s.estprice> 0)设置时FinalPrice = estprice-pricetop;万一;万一; IF(sbwynum> 0 AND topsbwynum!= hulsbwynum AND hulsbwynum!= sbwynum AND topsbwynum!= sbwynum AND topsbwynum> 0且hulsbwynum> 0)THEN IF(priceint> 0)THEN SET FinalPrice = priceint; ELSEIF(price> 0)THEN SET FinalPrice =价格-(pricetop + pricehulcons); ELSEIF(estprice> 0)THEN SET FinalPrice = estprice-(pricetop + pricehulcons);万一;万一; IF(sbwynum> 0 AND topsbwynum = hulsbwynum AND sbwynum!= hulsbwynum AND hulsbwynum> 0)IF(priceint> 0)时SET FinalPrice = priceint; ELSEIF(price> 0)THEN SET FinalPrice = price-pricetht; ELSEIF(estprice> 0)THEN SET FinalPrice = estprice-pricetht;万一;万一; IF(sbwynum> 0)时IF(FinalPrice> 0)时返回FinalPrice; ELSEIF(adjprice> 0)当返回adjprice时; ELSEIF(价格> 0)返回价格; ELSEIF(estprice> 0)返回时estprice;否则返回0;万一;否则返回0;万一; END // DELIMITER;

MySQL说:

1059-标识符名称'F_offshorePrice1(topsbwynum INTEGER,hulsbwynum INTEGER,sbwynum INTEGER,adjprice FLOAT(11,2),

PRI'太长

谁能告诉我使用EMS MANAGER 2007及其运行正确的cpanel but在mysql 5.1中此用户定义的函数出了什么问题。
非常感谢...

最佳答案

第一行:

CREATE FUNCTION `F_offshorePrice1(topsbwynum INTEGER...


尝试:

CREATE FUNCTION F_offshorePrice1(topsbwynum INTEGER...


或者,如果`字符应该存在,则它似乎没有匹配的结束符...

10-04 20:18