我的应用程序根据我的用例要求调用存储过程。存储过程将记录插入到由主键和外键约束相关的两个表中。
这意味着表中必须存在于PatientNumber
表中。Visit
Patient
当我调试此过程时,设置初始值后不显示任何值。
我是新手,请帮忙。
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Add_Patient_Visit]
AS
BEGIN TRANSACTION
SET NOCOUNT ON;
declare @Visit_Number Varchar(50)
declare @Prescription_Number Varchar(50)
declare @Visit_Date Datetime = GETDate()
set @Visit_Number = '25684956555'
set @Visit_Date = GETDATE()
set @Prescription_Number = '653214658'
INSERT INTO Visits(Visit_Number, Visit_Date, Patient_Number)
VALUES(@Visit_Number, @Visit_Date, @Patient_Number)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RETURN
END
declare @Patient_Number Varchar(50)
declare @FirstName Varchar(50)
declare @LastName Varchar(50)
declare @Trible Varchar(50)
declare @Gender Varchar(5)
declare @Date_Of_Birth Datetime
INSERT INTO Patient(Patient_Number, FirstName, LastName, Tribe, Gender, Date_Of_Birth)
VALUES (@Patient_Number, @FirstName, @LastName, @Trible, @Gender, @Date_Of_Birth)
IF @@ERROR <> 0
BEGIN
ROLLBACK
RETURN
END
COMMIT
GO