zoukankan      html  css  js  c++  java
  • 添加编辑、删除存储过程

    添加编辑存储过程:

    ALTER PROCEDURE [dbo].[ds_AwardAddOrUpd] 
        @a_id int,
        @aname varchar(20), 
        @imgurl varchar(512), 
        @award_description varchar(1000), 
        @exchange_description varchar(1000),
        @keyword varchar(30),
        @Return int output
    AS
    BEGIN
        set @Return=1
    
        if @a_id=0 --添加
        begin
            if not exists (select * from ds_award where aname=@aname and IsDelete=0)
            begin
                insert into ds_award (aname, imgurl, award_description, exchange_description, keyword, create_time,IsDelete)
                values (@aname,@imgurl,@award_description,@exchange_description,@keyword,getdate(),0)
            end
            else
            begin
                set @Return=2 --已经存在同名礼物
                return
            end
        end
        else --编辑
        begin
            update ds_award set aname=@aname, imgurl=@imgurl, award_description=@award_description, exchange_description=@exchange_description,keyword=@keyword
            where a_id=@a_id
        end
        
        if @@error<>0
        begin
            set @Return=0
            return
        end
    END

    删除存储过程:

    ALTER PROCEDURE [dbo].[ds_AwardDelete] 
        @a_id int,
        @Return int output
    AS
    BEGIN
        set @Return=1
    
        if (not exists (select * from ds_awardmgr where AID=@a_id and IsDel=0) and not exists (select * from ds_exchange where a_id=@a_id and [state]<>0))
        begin
            update ds_award set IsDelete=1 where a_id=@a_id
            delete from ds_exchange where a_id=@a_id
                
            if @@error<>0
            begin
                set @Return=0
                return
            end
        end
    
        else
        begin
            set @Return=2  --提示不可以删除
            return
        end
        
    END
  • 相关阅读:
    charles-Mock实践(数据修改)
    Git分支管理
    Git远程仓库
    Git安装与介绍
    IntelliJ IDEA安装
    Java-GUI
    How to deploy SSRS report from AX
    AX 2009 SSRS report installation and configuration
    How to create a menu item for SSRS report
    AX 2009 SSRS Report deploy language
  • 原文地址:https://www.cnblogs.com/wxh19860528/p/3412626.html
Copyright © 2011-2022 走看看