Solved

How to call a storedprocedure in MySql Query browser ??

Posted on 2009-05-18
2
3,953 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

Question has a verified solution.

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

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 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