我有一个将数据插入表的过程。我将要插入表(输入参数)的值声明为 Varchar 类型。但是表中 2 列的列类型已更改为 Int 类型。但程序仍在正确插入值。(基础表 IssuerGroupIDMapping 中的 IssuerId 和 Employer Id 列是 int 类型。)对我来说重要的问题是该程序在某些特定情况下会失败,我已经在 C# 中检查,以便只传递有效的整数进行。我需要立即更改代码吗?(对我来说有点问题,因为程序已经在生产中并且似乎正在运行。)。请建议。
以下是我的程序代码:
CREATE PROCEDURE [uspInsertIssuerGroupIDMapping]
@EmployerID Varchar(25),
@IssuerID Varchar(25),
@PlanID Varchar(25),
@IssuerGroupID Varchar(25),
@CreateUserID Varchar(25)
*****/
AS
BEGIN TRY
SET NOCOUNT ON
SET XACT_ABORT ON
--check to see if a duplicate trigger exists
IF ( NOT EXISTS (SELECT 1 FROM [IssuerGroupIDMapping]
WHERE EmployerId = @EmployerID AND PlanId = @PlanID)
)
BEGIN
INSERT INTO [IssuerGroupIDMapping]
([EmployerId]
,[IssuerId]
,[PlanId]
,[IssuerGroupID]
,[CreateUserId]
,[CreateDate]
,[UpdateUserId]
,[UpdateDate]
)
VALUES
(
@EmployerID
,@IssuerID
,@PlanID
,@IssuerGroupID
,@CreateUserId
,(SELECT Framework.udfGetTimeTravelDate())
,@CreateUserId
,(SELECT Framework.udfGetTimeTravelDate())
);
SELECT @@ROWCOUNT;
END
ELSE
BEGIN
--if a duplicate record exists update it
UPDATE [IssuerGroupIDMapping] SET
IssuerId = @IssuerID
,IssuerGroupID = @IssuerGroupID
,UpdateDate = (SELECT Framework.udfGetTimeTravelDate())
,UpdateUserId = @CreateUserID
WHERE EmployerId = @EmployerID
AND PlanId = @PlanID
SELECT @@ROWCOUNT;
END