create proceudre sp_insert( v_int_username char(50), v_in_password char(20), out v_out_result char(4) )
begin
insert into accounttb(account,passwd) values(v_int_username,v_in_password);
        /*
        不用事务控制 也不用select查询一遍
        如何判断插入的v_int_username是否已经存在,存在就set v_out_result = '0002';
        */
set v_out_result = '0000';
end;create proceudre sp_charge_password( v_int_username char(50), v_in_password char(20), out v_out_result char(4) )
begin
update accounttb set passwd=v_in_password where account = v_int_username;
        /*
        不用事务控制 也不用select查询一遍
        如何判断更新的v_int_username不存在,不存在就set v_out_result = '0001';
        */
set v_out_result = '0000';
end;上面这么做的目的不是结果是否对,而是我要知道返回的v_out_result值是什么!

解决方案 »

  1.   

    用insert ignore into 插入数据
    完了之后用row_count()判断是否插入
      

  2.   

    大神 我用了你说的row_count()
    但很奇怪
    select row_count();是OK的

    if row_count() > 0 then
        set v_out_result = '0002';
    else
        set v_out_result = '0000';
    select @v_out_result;
    v_out_result一直返回的是NULL;
    为什么?
      

  3.   

    应该把这个函数值into给一个变量吧
      

  4.   

    但得判断row_count()值 into怎么写呢?