zoukankan      html  css  js  c++  java
  • SQL游标写法代码

    作者:ejoe

    select adddate,pic,spic,* from product where code like '102805687%'  --56865


    select * from crk where ctype=6 and goods='10050709485658'
    select * from orders where goods='10050709485658'

    SELECT a.goods,a.id,b.code,a.productnum FROM orders a
    left join product b on b.id=a.id
    where a.goods='10050709485658'


    --insert into crk(goods,ctype,code,productnum,actname,comment)
    --values('10050709485658',6,'','','ejoe','平台单导错处理')
    --
    --update product set stock=stock+ ,jtkc=jtkc+ where id=

    declare @strCode nvarchar(20)
    declare @Num int   
    declare @intID int

    declare mycursor cursor for
    SELECT b.code,a.productnum,a.id FROM orders a
    left join product b on b.id=a.id
    where a.goods='10050709485658'

    open mycursor
    fetch next from mycursor into @strCode,@Num,@intID
    while(@@fetch_status=0)
    begin
        insert into crk(goods,ctype,code,productnum,actname,comment)
        values('10050709485658',6,@strCode,@Num,'ejoe','平台单导错处理');
        update product set stock=stock+@Num ,jtkc=jtkc+@Num where id=@intID;
    fetch next from mycursor into @strCode,@Num,@intID
    end
    close mycursor
    deallocate mycursor


     

  • 相关阅读:
    maven的安装和配置以及搭建项目应用
    Spring MVC与Struts2的区别(仅本人浅薄的理解)?
    记录学习PYTHON
    Zookeeper可以干什么
    Redis与Memcache的区别
    Redis持久化的两种方式和区别
    Scala 柯里化
    Redis与Memcached的区别
    高并发的处理策略
    序列化
  • 原文地址:https://www.cnblogs.com/911/p/1730306.html
Copyright © 2011-2022 走看看