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


     

  • 相关阅读:
    sizeof与strlen的区别
    面试题46:求1+2+...+n
    opennebula 安装指定参数
    opennebula 开发记录
    virsh 查看hypervisor特性
    opennebula kvm日志
    Cgroup
    opennebula kvm 创建VM oned报错日志
    opennebula kvm 创建虚拟机错误
    golang hello
  • 原文地址:https://www.cnblogs.com/911/p/1730306.html
Copyright © 2011-2022 走看看