zoukankan      html  css  js  c++  java
  • proc

    --判断数据是否存在记录存在修改,否则插入

    create proc HotLines_UpdateOrInsert
        
        
    @StartCity char(3)='',
        
    @EndCity char(3)='',
         
    @PriceDay1 money,
        
    @PriceDay2 money,
        
    @PriceDay3 money,
        
    @PriceDay4 money,
        
    @NumDay1 tinyint,
        
    @NumDay2 tinyint,
        
    @NumDay3 tinyint,
        
    @NumDay4 tinyint
    as
        
    Declare @count int
    --赋值
        set @count=0
    begin
        
    if(@StartCity is not null and @EndCity is not null)
            
    select @count=count(*
            
    from HotLines 
            
    where DepartureCity=@StartCity and DestinationCity=@EndCity
        
    if(@count<=0)
            
    Insert into HotLines
            (
                DepartureCity,
                DestinationCity,
                PriceDay1,
                PriceDay2,
                PriceDay3,
                PriceDay4,
                NumDay1,
                NumDay2,
                NumDay3,
                NumDay4
            ) 
            
    values
            (
                
    @StartCity,
                
    @EndCity,
                
    @PriceDay1,
                
    @PriceDay2,
                
    @PriceDay3,
                
    @PriceDay4,
                
    @NumDay1,
                
    @NumDay2,
                
    @NumDay3,
                
    @NumDay4
            )
        
    else
            
    Update HotLines set 
                PriceDay1
    =@PriceDay1,
                PriceDay2
    =@PriceDay2,
                PriceDay3
    =@PriceDay3,
                PriceDay4
    =@PriceDay4,
                NumDay1
    =@NumDay1,
                NumDay2
    =@NumDay2,
                NumDay3
    =@NumDay3,
                NumDay4
    =@NumDay4
            
    where DepartureCity=@StartCity and DestinationCity=@EndCity
        
    end

    GO
  • 相关阅读:
    解决mongod端口占用问题
    MongoDB操作
    ssh 带密码私钥 输入密码
    sequence
    使用plsql导入dmp文件缺少imp*.exe
    oracle查看锁表进程,杀掉锁表进程
    oracle
    常用shell命令
    ORA-03113: end-of-file on & ORA-07445
    ORA-39126: Worker unexpected fatal error in KUPW$WORKER.PUT_DDLS
  • 原文地址:https://www.cnblogs.com/jinweida/p/1260983.html
Copyright © 2011-2022 走看看