一个很简单的存储过程
CREATE DEFINER=`root`@`localhost` PROCEDURE `
create products on car`(Out product_id varchar(50), Out count int)
BEGIN
DECLARE unit_price int unsigned default 0;
DECLARE price int unsigned default 0;select b_price into unit_price
    from t_product where b_productId = @product_id;
    
set price = @unit_price * @count;INSERT INTO `bmbs`.`products_on_shopcar`
(
`product_id`,
`count`,
`price`)
VALUES
(
@product_id,
@count,
@price);END下面是调用
call `create products on car`('p001', 5);提示报错
14:19:32 call `create products on car`('p001', 5) Error Code: 1414. OUT or INOUT argument 1 for routine bmbs.create products on car is not a variable or NEW pseudo-variable in BEFORE trigger 0.000 sec网上说最后一个参数需要是OUT并且是返回值,不是很理解,我应该再定义存储过程参数的时候 ,在末尾多定义一个OUT型的参数吗?

解决方案 »

  1.   

    去掉out试试
      

  2.   

    楼主你好
           请问你的服务器的MySQL的版本号是多少,出这个问题看来你的MySQL服务器版本号应该小于5.5调用存储过程大致如下:
    在主存储过程里调用其他存储过程,调用的方式是pro = call p_insert_ad_report(?,?,?,?,?,?)
    然后在用execcute pro using @a,@b...
    出错的原因是5.5版本的mysql支持用using @a,@b传参数,而5.1版本不支持这样传参,只能用 call p_insert_ad_report(1,'haha');这样的格式调用存储过程最后一个参数是输出参数。因此必须使用一个变量。
    在MySQL Workbench中测试存储过程的时候变量不用定义直接使用即可。
    修改下面的调用方式,错误解决:call sp_page('table','ID','*','oreder by ID','',0,10,@total);
    select @total;