Solved

How to call a storedprocedure in MySql Query browser ??

Posted on 2009-05-18
2
3,717 Views
Last Modified: 2012-05-07
Hi experts,

 I have written the below sp in MySql..

 when i execute the sp by passing parameters like this...
 call sp_LoginCheck ('srk1','pwd');

I am getting error :

Error Code : 1318
Incorrect number of arguments for PROCEDURE demo.sp_LoginCheck; expected 3, got 2
(0 ms taken)

Which is wiered because, there are only 2 input parameters.
Am i missing something ?

Thanks.
DELIMITER $$
 

DROP PROCEDURE IF EXISTS `demo`.`sp_LoginCheck`$$
 

create PROCEDURE `demo`.`sp_LoginCheck`( 

 IN UserName1 varchar(50),

 IN Password1 varchar(50),

 OUT DoesExist bit)   

    BEGIN

 declare userCount INT default 0;

 SET DoesExist = 0; -- set to false initially, we'll assume for now it doesn't exist

 SELECT COUNT(Uid) INTO userCount

 FROM tbl_Users

 WHERE username = username1 and password=password1;

 IF userCount > 0 THEN

  SET DoesExist = 1;  -- more then one returned, return true

 END IF;

    END$$
 

DELIMITER ;

Open in new window

0
Comment
Question by:srk1982
2 Comments
 
LVL 3

Accepted Solution

by:
DABOMB earned 250 total points
Comment Utility
You will notice that there are 3 parameters to the function call, you have the first 2 correct as they are inputs, but you must pass a variable to capture the output.

call sp_LoginCheck ('srk1','pwd',@MYVAR);

then you can use

SELECT @MYVAR\G

which would return DoesExist (0 or 1)
0
 

Author Closing Comment

by:srk1982
Comment Utility
Thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
This video discusses moving either the default database or any database to a new volume.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now