Stored Procedure Creation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinot85
    New Member
    • Aug 2007
    • 53

    Stored Procedure Creation

    Hello to everyone. Im using MySQL 5.0. I am trying to create a simple stored procedure like,

    Code:
     
    CREATE PROCEDURE login_authenticate(IN uname varchar(50), IN pwd varchar(50), INOUT status)
    BEGIN
          DECLARE tcount INT DEFAULT 0;
          select count(*) into tcount from login where username=uname  and password=pwd;
          if tcount > 0 then
               set status = 1
         end if;
         if tcount = 0 then
              set status = 0
        end if;
    END;
    This procedure is having exact syntax given in MySQL 5.0 Manual.

    If i run this code in MYSQL Command Prompt, it shows errors like,

    1.Invalid syntax, Check the MySQL Manual Corresponds to this.
    2.Undeclared variable tcount.


    What is wrong with the code?
    Help me Soon.

    Regards,

    Vinoth.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    I see two problems with that code.

    First, your INOUT status variable is missing a type. I suspect you forgot to add the "boolean" keyword at the end of the parameter declaration.

    And second, both the lines where you try to set the value of the status variable are missing the semi-colon at the end of the line. Those are required, or you will get syntax errors.

    Comment

    Working...