469,612 Members | 1,605 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

Stored Procedure Creation

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

Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE PROCEDURE login_authenticate(IN uname varchar(50), IN pwd varchar(50), INOUT status)
  3. BEGIN
  4.       DECLARE tcount INT DEFAULT 0;
  5.       select count(*) into tcount from login where username=uname  and password=pwd;
  6.       if tcount > 0 then
  7.            set status = 1
  8.      end if;
  9.      if tcount = 0 then
  10.           set status = 0
  11.     end if;
  12. END;
  13.  
  14.  
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.
Jan 22 '09 #1
1 2014
Atli
5,058 Expert 4TB
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.
Jan 22 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Douglas Buchanan | last post: by
2 posts views Thread by GaryDean | last post: by
reply views Thread by SOI_0152 | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.