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


     

  • 相关阅读:
    Kth Smallest Element in a BST
    Bitwise AND of Numbers Range
    Happy Number
    Summary Ranges
    linux设置MySQL开机自动启动
    基本PSO算法实现(Java)
    Invert Binary Tree
    Rectangle Area
    Contains Duplicate II
    Contains Duplicate
  • 原文地址:https://www.cnblogs.com/911/p/1730306.html
Copyright © 2011-2022 走看看