2
votes

Having trouble getting this to apply in MySQL Workbench 5.2.15

DELIMITER //

CREATE 
    DEFINER=`potts`@`%` 
    FUNCTION 
        `potts`.`fn_create_category_test`  (test_arg VARCHAR(50))
    RETURNS int

BEGIN

    DECLARE new_id int;
    SET new_id = 8;
    RETURN new_id;

END//

The actual function will have a lot more between BEGIN and END but as it stands, even this 3 liner won't work.

Thanks!

1
What error message do you get?Nifle
it works for me. obvious possible problems: does the database potts exist? Doesn't the function fn_create_category_test exist already in potts? Does the user potts' exist? Does the user potts` have the necessary privileges to create a function in the database potts ?Roland Bouman
yes, no, yes and yes. i'm putting it down to a bug in that version, it now runs fine in mysql query browserMatthew

1 Answers

1
votes

DELIMITER $$

CREATE FUNCTION `fn_create_category_test` (test_arg varchar(50))
   RETURNS INT
BEGIN

DECLARE new_id int;
set new_id=8;
return new_id;
END $$

DELIMITER ;

Works fine for me, try getting rid of DEFINER?