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设成变量

    评论

报告相同问题?

悬赏问题

  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的