returnMsg out varchar2 ) as cardState TB_MEM_MEM_CARD_RES_REL.MEMBER_CARD_STATE%type; --cardState char(4);
is_valid number(4); v_sql varchar2(2000); v_temp varchar2(2000); begin --传的值进行非空验证
if(option_type !=1 and option_type!=2)or(check_type!=1 and check_type!=2)or(member_id isnull)or(latn_id isnull) then returnMsg :='调用该存储过程,传的参数不对!'; return; endif; if(check_type='2')then if(card_pwd isnull)then returnMsg :='采用会员卡验证,会员卡密码不能为空!'; return; endif; endif; --查询会员卡状态
v_sql:='select MEMBER_CARD_STATE from TB_MEM_MEM_CARD_RES_REL where MEMBER_ID ='|| member_id; --dbms_output.put_line(v_sql||CHR(10));
executeimmediate v_sql into cardState; v_sql :='select count(MEMBER_ID) from TB_MEM_MEMBER_'|| latn_id ||' where MEMBER_ID={memberid} and PASSWORD={pwd}'; v_sql :=replace(v_sql,'{memberid}',member_id); v_sql :=replace(v_sql,'{pwd}',card_pwd); --挂失
if option_type ='1'then begin if cardState='1'then begin if check_type ='1'then v_temp :='update TB_MEM_MEM_CARD_RES_REL set MEMBER_CARD_STATE=3 where MEMBER_ID ='|| member_id; executeimmediate v_temp; returnMsg :='挂失成功!'; elsif check_type ='2'then begin --立即执行
executeimmediate v_sql into is_valid; if is_valid =1 then v_temp :='update TB_MEM_MEM_CARD_RES_REL set MEMBER_CARD_STATE=3 where MEMBER_ID ='|| member_id; executeimmediate v_temp; returnMsg :='挂失成功!'; else returnMsg :='会员卡密码不正确!'; return; endif; end; endif; end; else returnMsg :='会员卡状态不是有效状态不能挂失!'; return; endif; end; --解挂
elsif option_type ='2'then begin if cardState='3'then begin if check_type ='1'then v_temp :='update TB_MEM_MEM_CARD_RES_REL set MEMBER_CARD_STATE=1 where MEMBER_ID ='|| member_id; executeimmediate v_temp; returnMsg :='解挂成功!'; elsif check_type ='2'then begin --立即执行
executeimmediate v_sql into is_valid; if is_valid =1 then v_temp :='update TB_MEM_MEM_CARD_RES_REL set MEMBER_CARD_STATE=1 where MEMBER_ID ='|| member_id; executeimmediate v_temp; returnMsg :='解挂成功!'; else returnMsg :='会员卡密码不正确!'; return; endif; end; endif; end; else returnMsg :='会员卡状态不是挂失状态不能解挂!'; return; endif; end; endif; commit; exception when others then returnMsg :='内部错误'||sqlerrm; --dbms_output.put_line('ky' || sqlerrm);