Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to call a storedprocedure in MySql Query browser ??

Posted on 2009-05-18
2
Medium Priority
?
4,216 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 1000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

926 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