【发布时间】:2020-03-06 09:27:05
【问题描述】:
我有两个表 Tbl_Appointment 和 Tbl_AppointmentRequest。 Tbl_AppointmentRequest 中的数据来自移动应用程序,在 UI 中有一个按钮批准,单击它会用 Tbl_AppointmentRequest 的数据填充文本框、下拉列表等,然后有一个称为提交的按钮,当我提交它时,它会将数据插入 Tbl_Appointment 并插入时Tbl_AppointmentRequest 中有一个列 isappconfirm 应该更新为 1。 以下是我的查询,我可以插入但无法将 isappconfirm 列更新为 1。
ALTER Proc [dbo].[Sp_Save_Appointment]
(@AppointmentID nvarchar(50),
@PatientID nvarchar(50),
@PatientName nvarchar(500),
--@PackageID nvarchar(50),
@PackageName nvarchar(500),
@Date nvarchar(50),
@Time nvarchar(50),
@DoctorID nvarchar(50),
@DoctorName nvarchar(500),
@HospitalName nvarchar(500),
@Address nvarchar(500),
@Price nvarchar(500),
@Latitude nvarchar(50),
@Longitude nvarchar(50),
@EscortName nvarchar(500),
@Createdby nvarchar(50),
@CreatedbyName nvarchar(500),
@Modifiedby nvarchar(50),
@ModifiedbyName nvarchar(500))
as begin
if(@AppointmentID='')
begin
Insert into Tbl_Appointment(PatientID,PatientName,PackageName,Date,Time,DoctorID,DoctorName,HospitalName,
Address,Price,Latitude,Longitude,EscortName,Createdby,CreatedbyName,CreatedDate)
values(@PatientID,(Select Top(1)PatientName from Tbl_Patientinfo where PatientID=@PatientID),
@PackageName,
@Date,@Time,@DoctorID,(Select Top(1) DoctorName from Tbl_DoctorInfo where DoctorID=@DoctorID),
@HospitalName,@Address,@Price,@Latitude,@Longitude,@EscortName,
@Createdby,(Select Top(1)UserName from Tbl_UserInfo where UserId=@Createdby),
convert(datetime,SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30')))
Declare @id nvarchar(20) set @id=@@identity
select @id as message
end
else
begin
Update Tbl_Appointment Set PatientID=@PatientID,@PatientName=(Select Top(1)PatientName from Tbl_Patientinfo where PatientID=@PatientID),
PackageName=@PackageName,
Date=@Date,Time=@Time,DoctorID=@DoctorID,DoctorName=(Select Top(1) DoctorName from Tbl_DoctorInfo where DoctorID=@DoctorID),
HospitalName=@HospitalName,Address=@Address,Price=@Price,Latitude=@Latitude,Longitude=@Longitude,EscortName=@EscortName,
Modifiedby=@Modifiedby,ModifiedbyName=@ModifiedbyName,ModifiedDate=convert(datetime,SWITCHOFFSET(SYSDATETIMEOFFSET(), '+05:30'))
Where AppointmentID=@AppointmentID
Select '1' as message
declare @isappconfirm nvarchar(50)
set @isappconfirm=(select top(1) isappconfirm from Tbl_AppointmentRequest where AppointmentReqID=@AppointmentID order by AppointmentReqID desc)
if(@isappconfirm='')
begin
update Tbl_AppointmentRequest set isappconfirm='1' where AppointmentReqID=@AppointmentID
end
end
end
【问题讨论】:
标签: sql sql-server asp.net-mvc