• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

Trying to execute the below simple function on Mysql 5.1 - getting error

DELIMITER $$
CREATE FUNCTION MChildren.SLastnameTest()
BEGIN
declare lname varchar(50);
SELECT lastname INTO lname FROM MChildren.Children where children.callid = 583;
return lname
END$$
DELIMITER;
0
Jsara
Asked:
Jsara
  • 3
1 Solution
 
_agx_Commented:
please post the error message
0
 
JsaraAuthor Commented:
THe error message is
"You tried to execute an
empty string. Please type an SQL command into the SQL edit field and execute again".
0
 
_agx_Commented:
I think you're missing a return type.  

Also if you're running it mysql query analyzer use:

      script > create stored procedure/ function > (enter function name) > create function

DELIMITER $$
CREATE FUNCTION `MChildren`.`SLastnameTest` () RETURNS VARCHAR(50)
BEGIN
declare lname varchar(50);
SELECT lastname INTO lname FROM Children where children.callid = 583;
RETURN lname;
END $$
DELIMITER ;

Open in new window

0
 
_agx_Commented:
Correction: I dropped a reference to "MChildren" in the SELECT

ie
SELECT lastname INTO lname FROM MChildren.Children where children.callid = 583;
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now