sql会话

作者: 成熟的青菜 | 来源:发表于2017-04-20 11:05 被阅读24次

    <pre><code>

    alter PROCEDURE [BAD_GET_BASE_INFO]
    @unit int,
    @billno varchar(30)
    AS
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

    declare @count int
    IF(@unit>0)
    SELECT @count=count() FROM bad WHERE unit=@unit
    else
    SELECT @count=count(
    ) FROM bad WHERE unit=(SELECT top 1 unit FROM b_tyd WHERE billno=@billno)

    IF(@count>0)
    begin
    declare @s varchar(1000)
    set @s='运单号为%d(货号为%s)的运单已经登记过货损信息了!'+char(13)+char(10)+'如果需要修改,请在营运中心-异常登记中处理!'
    raiserror(@s,16,1,@unit,@billno)
    end
    else
    begin
    IF(@billno='' or (@unit <> 0 AND @billno <> '')) --按运单号
    SELECT unit,billno,product,qty,package,billdate, bsite,esite,shipper,consignee, accdeclare,accsafe FROM b_tyd WHERE unit=@unit

     IF(@unit=0) --按货号
        SELECT  unit,billno,product,qty,package,billdate, bsite,esite,shipper,consignee, accdeclare,accsafe  FROM b_tyd  WHERE  billno=@billno
    

    end
    </pre></code>

    相关文章

      网友评论

          本文标题:sql会话

          本文链接:https://www.haomeiwen.com/subject/avokzttx.html