sinat_36169916 2016-09-19 06:37 采纳率: 0%
浏览 864

帮忙把sql语句写入存储过程。

请大神帮忙把这两段sql语句写入一个存储过程里,并且把表名设为变量,因为每次执行这段语句需要修改表名table_11 ,谢谢

select * from tab1 for update

create table tab_11 as

select *

from v_number

where pcode = 20161408

and scode in

   (select scode from tab1)

delete from v_number

where = 20161408

and scode in

   (select scode from tab1)

---285

insert into v_number

select 20161408,

     a.scode,

     a.ICODE,

from v_number a

where (a.pcode ,a.scode) in (select copy,scode from tab1)

delete from r_item

where pcode = 20161408

and scode in

(select scode from tab1)

insert into r_item

select 20161408, scode, percent

from r_item

where (pcode , scode) in

   (select copy,scode from tab1)

select * from tab2 for update

create table tab2_20161408 as

select * from ra_number where pcode=20161408

and (scode,cy) in (select scode,cy from tab2)

delete from ra_number where pcode=20161408

and (scode,cy) in (select scode,cy from tab2)

insert into ra_number

select 20161408,

   a.scode,

   a.ITEMCODE

from ra_number a where (a.pcode,a.scode,a.cy) in

(select copy,scode,cy from tab2)

insert into v_number

select 20161408,

     a.scode,

     a.ICODE,

from v_number a

where (a.pcode ,a.scode) in (select copy,scode from tab2)

  • 写回答

2条回答 默认 最新

  • AlbertS 博客专家认证 2016-09-19 07:08
    关注

    要把tab_11设成变量还是tab1设成变量

    评论

报告相同问题?

悬赏问题

  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)