472,127 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

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 2059
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.