DELIMITER $$DROP FUNCTION IF EXISTS `wellmeadows`.`positions` $$
CREATE FUNCTION `wellmeadows`.`positions` (@po_code varchar) RETURNS varchar(45)
BEGIN
declare po varchar
po=@po_code
select po_describe from positions where po=po_code
return po_describe
END $$DELIMITER ;以上是代码 ..  我有一个表是positions 有两个column 一个是po_code 用来放职位代码的 另一个是po_describe 是用来放职位的描述
其它表调用的都是po_code, 所以我想写一个function用来返回po_describe. 
我这样写,mysql说我Script line: 4 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 '@po_code varchar) RETURNS varchar(45)
BEGIN
declare po varchar
po=@po_code
s' at line 1请问应该怎样改呢??  谢谢..

解决方案 »

  1.   

    Script line: 4 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 ') RETURNS varchar(45)
    BEGIN
    declare po varchar
    po=@po_code
    select po_describ' at line 1
      

  2.   

    没变阿..我将代码改成DELIMITER $$DROP FUNCTION IF EXISTS `wellmeadows`.`positions` $$
    CREATE FUNCTION `wellmeadows`.`positions` (po_code varchar(5)) RETURNS varchar(45)
    BEGIN
    declare po varchar(5)
    po=po_code
    select po_describe from positions where po=po_code
    return po_describe
    END $$DELIMITER ;错误变了地方Script line: 4 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 'po=po_code
    select po_describe from positions where po=po_code
    return po_descri' at line 4
      

  3.   

    declare po varchar(5) 
    po=po_code 
    唔要
      

  4.   

    楼上系广东人呢... 点解唔要阿?? 依家变左return嘎问题了.. return po_describe
    END $$距话呢句出问题. 
      

  5.   

    into po_describe 
    最后
      

  6.   

    return into??  唔得阿. 
      

  7.   

    select po_describe from positions where po=po_code into po_code
      

  8.   

    DELIMITER $$DROP FUNCTION IF EXISTS `wellmeadows`.`positions` $$
    CREATE FUNCTION `wellmeadows`.`positions` (po_code varchar(5)) RETURNS varchar(45)
    BEGIN
    select po_describe from positions where po=po_code into po_code
    return po_describe
    END $$DELIMITER ;还是不行..
    Script line: 4 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 'return po_describe
    END' at line 4
      

  9.   

    DROP FUNCTION IF EXISTS `wellmeadows`.`positions` $$ 
    CREATE FUNCTION `wellmeadows`.`positions` (po_code varchar(5)) RETURNS varchar(45) 
    BEGIN 
    select po_describe from positions where po=po_code into @hh
    return @hh
    END $$ 
      

  10.   

    DELIMITER $$DROP FUNCTION IF EXISTS `wellmeadows`.`positions` $$
    CREATE FUNCTION `wellmeadows`.`positions` ($po_code varchar(255)) RETURNS varchar(45)
    BEGIN
    declare $po_describe varchar(45);
    select po_describe from positions where po_code = $pa_code into $po_describe;
    return $po_describe;
    END$$DELIMITER ;