基本上当我注册时(注册详细信息转到登录表),此数据将转到2个表:
使用@Attrib
我检查哪些数据需要转到哪个表。但是我在第一个else
部分附近收到错误。
错误是:
'@Attrib'附近的语法错误,期待SELECT或'('
以下是代码:
ALTER procedure [dbo].[Registration_SP]
(
@Email varchar(50),
@Password varchar(50),
@Repassword varchar(50),
@Attrib varchar(50)
)
AS
BEGIN
Insert into Login (Email,Password,Repassword,Attrib)
values(@Email,@Password,@Repassword,@Attrib)
IF (@Attrib = 'Student')
BEGIN
Insert into StudentReg
(StudentId,FirstName,LastName,Gender,Address1,Address2,Address3,
LandPhone,MobilePhone,Budget,IsFinancialSupport,CourseName,
IsJobSeeker,Country,Region,IsSupportActive,RegDate,ImagePath,
ShortCode)
Values(@Email,'','','','','','','','','','','','','','','','','','')
END
ELSE (@Attrib = 'Financial Supporter')
BEGIN
Insert into SupporterReg
(SupporterId,SupporterName,University,ContactNo,StudentLocation,RegDate,
ImagePath,ShortCode)
Values(@Email,'','','','','','','')
END
进一步澄清,我已经附上了下面的图片:
答案 0 :(得分:7)
之后您的ELSE
遗失IF
:
即
ELSE (@Attrib = 'Financial Supporter')
应该是
ELSE IF (@Attrib = 'Financial Supporter')
答案 1 :(得分:6)
ELSE
案例没有条件,因此会报告语法错误。
-- Should be no condition here, syntax error.
ELSE (@Attrib = 'Financial Supporter')
我认为您打算将其作为ELSE IF
ELSE
IF (@Attrib = 'Financial Supporter')