• 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


     

  • 相关阅读:
    linux笔记
    初探hook的键盘获取
    python pyHook安装
    转: ZigBee/Z-Stack CC2530实现低功耗运行的配置简介
    三种zigbee网络架构详解
    adc verilog spi 时序
    dac verilog ad5601
    verilog 三段式状态机的技巧
    fpga 状态机 检测1011序列
    lattice diamond fpga 状态机的理解
  • 原文地址:https://www.cnblogs.com/911/p/1730306.html
Copyright © 2020-2023  润新知