更新storedprocedure不更新表数据 [英] Update storedprocedure not updating table data

查看:72
本文介绍了更新storedprocedure不更新表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表格脚本为---



Table script as ---

CREATE TABLE [dbo].[JS_ResumeInsert](
        [JS_Id] [int] NULL,
        [UserEmailId] [varchar](150) NULL,
        [Name] [varchar](50) NULL,
        [Phone] [varchar](200) NULL,
        [Institute] [varchar](100) NULL,
        [Batch] [varchar](50) NULL,
        [Designation] [varchar](100) NULL,
        [Organization] [varchar](100) NULL,
        [Experience_Months] [varchar](10) NULL,
        [Experience_Years] [varchar](10) NULL,
        [TotalExp] [int] NULL,
        [Industry] [varchar](300) NULL,
        [CurrentLocation] [varchar](100) NULL,
        [PreferredLocation] [varchar](100) NULL,
        [IsInserted] [int] NULL,
        [IsUpdated] [int] NULL,
        [CreationDate] [datetime] NULL
    )









存储过程为---









storedprocedure as---


CREATE PROCEDURE JSP_ResumeUpdate  
       
     @JS_Id [int],  
     @UserEmailId [varchar](150),  
     @Name [varchar](50),  
     @Phone [varchar](200) ,  
     @Institute [varchar](100) ,  
     @Batch varchar(50),  
     @Designation varchar(100),  
     @Organization varchar(100) ,  
     @Experience_Months varchar(10),  
     @Experience_Years varchar(10) ,  
     @TotalExp int ,  
     @Industry varchar(300),  
     @CurrentLocation varchar(100) ,  
     @PreferredLocation varchar(100) ,  
     @IsInserted int ,  
     @IsUpdated int ,   
     @Result Tinyint OutPut      
          
    AS              
     BEGIN                    
          
          IF EXISTS(SELECT  * FROM  JS_ResumeInsert WHERE UserEmailId =@UserEmailId )                  
     BEGIN                    
       SET @Result = 0-- Already Exists                    
     END                    
               
     ELSE                    
      BEGIN     
          
       
      UPDATE  JS_ResumeInsert SET    
       
         JS_Id=@JS_Id ,  
         UserEmailId=@UserEmailId ,  
      Name=@Name ,  
      Phone=@Phone ,  
      Institute=@Institute  ,  
      Batch=@Batch ,  
      Designation=@Designation ,  
      Organization=@Organization ,  
      Experience_Months=@Experience_Months,  
      Experience_Years=@Experience_Years ,  
      TotalExp=@TotalExp ,  
      Industry=@Industry ,  
      CurrentLocation=@CurrentLocation ,  
      PreferredLocation=@PreferredLocation  ,  
      IsInserted=@IsInserted ,  
      IsUpdated=@IsUpdated ,  
      CreationDate=GETDATE()  
          
       
     set @Result =1                 
     return      
        
     END  
    END

推荐答案

Well..well,



你说你的表中有数据,所以你的SP中的第一个条件自然是真的



你的更新声明是在ELSE中,所以它永远不会执行。



第二个也是非常重要的一点,你在UPDATE语句中没有where子句,这将更新 ALL 传递数据的表行。



Hoep有帮助。如果是,请将其标记为答案/ upvote。

Milind
Well..well,

You are saying you have data in the table so naturally the first condition in your SP will be true

Your update statement is in ELSE, so it will never execute.

Second and very important point, you do not have "where" clause in the UPDATE statement, this will update ALLThe rows of the table with the data passed.

Hoep that helps. If it does, mark it as answer/upvote.
Milind


您好..



你用什么语法来执行这个程序?



我最好的猜测是你已经创建了你的程序,但你还没有执行它。



如果有,请发布其代码,可能会有一些错误。



Hi..

What syntax are you using to execute this procedure??

My best guess is that you have created your procedure, but you haven''t executed it.

If you have, please post its code, there might be some error in that.

ALTER PROCEDURE dbo.Test @ip  VARCHAR(10),
                       @op VARCHAR(20) output







DECLARE @x VARCHAR(20);

EXEC dbo.Test "Test", @op output
 
SELECT @op





希望它有所帮助...



干杯



Hope it helps...

Cheers


这篇关于更新storedprocedure不更新表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆