当满足以下任一条件时,我希望代码进入下一个执行步骤:
- 名字、姓氏和出生日期:这三个都不为空
- ID 和 DOB 不为空
- SSN 和 DOB 不为空
- ID 和 Group Number 不为空
下面是我的代码。当我通过提供名字、姓氏和出生日期来运行它时(满足条件 1),它仍然失败,说条件 4 不满足。有人可以告诉我我做错了什么吗?
IF ( ( @FirstName IS NULL
OR Len(Ltrim(@FirstName)) = 0 )
AND ( @LastName IS NULL
OR Len(Ltrim(@LastName)) = 0 )
AND ( @DOB IS NULL ) )
BEGIN
INSERT INTO @ValidationError
(errormessage)
VALUES ( 'first name, last name and Date of Birth must be specified.'
)
END
ELSE
BEGIN
IF ( @DOB IS NULL
AND @Id IS NULL )
BEGIN
INSERT INTO @ValidationError
(errormessage)
VALUES ( 'Date of Birth and Id must be specified.' )
END
ELSE
BEGIN
IF ( @DOB IS NULL
AND @SSN IS NULL )
BEGIN
INSERT INTO @ValidationError
(errormessage)
VALUES ( 'Date of Birth and SSN must be specified.' )
END
ELSE
BEGIN
IF ( @Id IS NULL
AND @GroupNumber IS NULL )
BEGIN
INSERT INTO @ValidationError
(errormessage)
VALUES ( 'Id and Group Number must be specified.' )
END
END
END
END