Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2010
    Posts
    1

    Unanswered: How to call Function from a Stored Procedure?

    Hello,

    I was hoping someone could tell me how you go about creating a stored procedure that calls a user function... everytime I create a function and then try to create a stored procedure that uses it, I get a syntax error.

    i.e.

    CREATE FUNCTION FUNC1(str1 VARCHAR(100))
    BEGIN
    /*do something*/
    END

    CREATE PROCEDURE PROC1(in str2 VARCHAR(100))
    BEGIN
    DECLARE x VARCHAR(100);

    SET x = FUNC1(str1);

    /*output or do something else*/
    END

    Thanks in advance for your help.

  2. #2
    Join Date
    Jun 2010
    Posts
    4
    I think you missed the return type,

    CREATE FUNCTION FUNC1(str1 VARCHAR(100))
    RETURNS VARCHAR(100)
    BEGIN
    /*do something*/
    RETURN retstr;
    END

    CREATE PROCEDURE PROC1(in str2 VARCHAR(100))
    BEGIN
    DECLARE x VARCHAR(100);

    SET x = FUNC1(str1);

    /*output or do something else*/
    END

    If it's not working, mention the error msg.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •