views:

22

answers:

2

Hi

I m calling a stored procedure inside another stored procedure in MySQL

The error i m getting on calling simply using Mysql administrator

call sp_update_back_image(2, 3);

is: -

OUT or INOUT argument 2 for routine void.sp_sel_options_id is not a variable 
or NEW pseudo-variable in BEFORE trigger

The stored procedures...

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_update_back_image`(uid int , img_id int)
BEGIN
call sp_sel_options_id(uid, oid);
select oid;
END

The sp_sel_options_id is: -

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_sel_options_id`(IN uid int, 
OUT r_id int)
BEGIN
    set r_id = 0;
END

Any Help

Thanks

Pradyut

India

A: 

sp_update_back_image seems to be using something called oid that is not declared anywhere. Should it be using img_id instead?

CREATE DEFINER=`root`@`localhost` PROCEDURE 
             `sp_update_back_image`(uid int , img_id int)
BEGIN
call sp_sel_options_id(uid, img_id);
select img_id;
END
Martin Smith
A: 

yup

the other variable needs to initialized or ordered in the calling variables...

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_update_back_image`(uid int , img_id int)
BEGIN
declare oid int;
call sp_sel_options_id(uid, oid);
select oid;
END
Pradyut Bhattacharya