Solved

How to call a storedprocedure in MySql Query browser ??

Posted on 2009-05-18
2
3,780 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
ID: 24419187
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
ID: 31582848
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

17 Experts available now in Live!

Get 1:1 Help Now