oracle带参数的存储过程

语法弄了半天发出来备份个



--新增影城微信支付方式
create or replace procedure insert_cinema_weixin(cinema_id in varchar2 ) as     
   cinema_name_tmp varchar2(400);
  begin
  --判断传入值是否合法
   if(cinema_id is null   or length(cinema_id) <2) then
      return;
    end if;    
    --插入数据
insert into table1
values
  (cinema_id||'-12-08', cinema_id, 1, '兑换券', 12, '微信', 3);
insert into table1
values
  (cinema_id||'-12-09', cinema_id, 2, '优享卡', 12, '微信', 3);
insert into table1
values
  (cinema_id||'-12-07', cinema_id, 4, '次卡', 12, '微信', 3);
insert into table1
values
  (cinema_id||'-12-06', cinema_id, 6, '积分', 12, '微信', 3);
insert into table1
values
  (cinema_id||'-12-05', cinema_id, 5, '礼券', 12, '微信', 3);


--获得影城名称
 select  max(c.cinema_name) into cinema_name_tmp from table2 c where c.pho_cinema_id=cinema_id and rownum=1;

--id对应的值替换相应的影城id;影城ID替换对应ID;影院名称替换对应名称
insert
  into table3 (id,partner_id,pay_id,cinema_id,partner_name,partner_key) values('wechat-'||cinema_id,
                                     '1232334702',
                                     '7',
                                     cinema_id,
                                     cinema_name_tmp,
                                     'd0b0acd885d823b203835dcbd3ed8bd1'
                                   );
end insert_cinema_weixin;
 

--调用 新影城支付 execute insert_cinema_weixin('影城cinema_id');

commit;


 

--确认是否正确添加I select * from table1 p where 1=1 and p.paymode_name='微信' and p.cinema_id='304'
--确认是否正确添加II select * from table3 pp where 1=1 and pp.partner_id='1232334702' and pp.cinema_id='304'
--删除 drop procedure insert_cinema_weixin;
--  call  insert_cinema_weixin('304');调用 输入影城ID


你可能感兴趣的:(oracle带参数的存储过程)