If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > store procedure error- parameter mismatched

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-11-11, 10:24
rohitamitpathak rohitamitpathak is offline
Registered User
 
Join Date: Feb 2011
Location: india- new delhi
Posts: 31
store procedure error- parameter mismatched

my sp is
DELIMITER $$

DROP PROCEDURE IF EXISTS `zero`.`sp_for_insert_into_account_db`$$
CREATE PROCEDURE `zero`.`sp_for_insert_into_account_db` (usr_key char(6),usr_name varchar(15),usr_password varchar(15),OUT output_message INT)
BEGIN
DECLARE no_of_row INT;

SELECT COUNT(*) INTO no_of_row from account_db;

IF no_of_row < 4 THEN

SET @s = CONCAT('insert into account_db (USR_KEY,USR_NAME,USR_PWD) VALUES (',usr_key,usr_name,usr_password,')');

PREPARE stmt FROM @s;

EXECUTE stmt;

DEALLOCATE PREPARE stmt;

SET output_message=1;

ELSE

SET output_message=0;



END IF;
END$$

DELIMITER ;

i m calling it with query
call sp_for_insert_into_account_db('a','b','c',@output_ message);
i think this is correct... still it is showing error like
coloum count does not match value... i m passing 4 argument.....
pls tell me why this error is occour ..........

i already check with this syntax (by default parameter is IN type)
`sp_for_insert_into_account_db`(IN usr_key char(6),IN usr_name varchar(15), IN usr_password varchar(15),OUT output_message INT)
__________________
Amit Pathak
S/w Developer
Zero Systems Pvt Ltd..

Last edited by rohitamitpathak; 03-11-11 at 10:29.
Reply With Quote
  #2 (permalink)  
Old 03-14-11, 03:21
rohitamitpathak rohitamitpathak is offline
Registered User
 
Join Date: Feb 2011
Location: india- new delhi
Posts: 31
I got the solution...

Quote:
Originally Posted by rohitamitpathak View Post
my sp is
DELIMITER $$

DROP PROCEDURE IF EXISTS `zero`.`sp_for_insert_into_account_db`$$
CREATE PROCEDURE `zero`.`sp_for_insert_into_account_db` (usr_key char(6),usr_name varchar(15),usr_password varchar(15),OUT output_message INT)
BEGIN
DECLARE no_of_row INT;

SELECT COUNT(*) INTO no_of_row from account_db;

IF no_of_row < 4 THEN

SET @s = CONCAT('insert into account_db (USR_KEY,USR_NAME,USR_PWD) VALUES (',usr_key,usr_name,usr_password,')');

PREPARE stmt FROM @s;

EXECUTE stmt;

DEALLOCATE PREPARE stmt;

SET output_message=1;

ELSE

SET output_message=0;



END IF;
END$$

DELIMITER ;

i m calling it with query
call sp_for_insert_into_account_db('a','b','c',@output_ message);
i think this is correct... still it is showing error like
coloum count does not match value... i m passing 4 argument.....
pls tell me why this error is occour ..........

i already check with this syntax (by default parameter is IN type)
`sp_for_insert_into_account_db`(IN usr_key char(6),IN usr_name varchar(15), IN usr_password varchar(15),OUT output_message INT)
Basically in this scenario there are no need to use prepared statement, i was using this with wrong syntax-
BEFORE:-

SET @s = CONCAT('insert into account_db (USR_KEY,USR_NAME,USR_PWD) VALUES (',usr_key,usr_name,usr_password,')');

WRITE SYNTAX IS-

SET @s = CONCAT('insert into account_db (USR_KEY,USR_NAME,USR_PWD) VALUES (\'',usr_key,'\',\'',usr_name,'\',\'',usr_password ,'\')');
You can also do this without prepared statement, for this use

insert into account_db (USR_KEY,USR_NAME,USR_PWD) VALUES (usr_key,usr_name,usr_password) ;
__________________
Amit Pathak
S/w Developer
Zero Systems Pvt Ltd..
Reply With Quote
Reply

Tags
mysql stored procedure

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On