我正在编写插入和更新的存储过程,但我不知道如何将复合键添加到过程中。
对于插入:
create procedure sp_ParagraphInoviceInsert
(@pName nvarchar(255),
@pPrice nvarchar (255),
@pDeviceID int,
@pServiceID int,
@pDate date,
@pBillID int ---->This is the other part of composite key, do I add here?
)
as
begin
begin transaction
insert into ParagraphInovice(Name, Price, device, service, date, bilID)
values(@pname, @pPrice,....)
if @@ERROR <> 0
begin
rollback
end
else
begin
commit
end
end
更新
create procedure sp_ParagraphInoviceUpdate
(@pParagraphInoviceID int,
@pName nvarchar(255),
@pPrice nvarchar (255),
@pDeviceID int,
@pServiceID int,
@pDate date,
@pBillID int)
as
begin
begin transaction
update ParagraphInovice
set name = @pName,
price = @pPrice,
device = @pDeviceID,
service = @pServiceID,
date = @pDate,
billID = @pBillID
where
ParagraphInoviceID = @pParagraphInoviceID
if @@ERROR <> 0
begin
rollback
end
else
begin
commit
end
end
go
所以我的表由复合键ParagraphInovice(main)和bill(复合)组成。
这个程序有什么问题?
谢谢,