Database Reference
In-Depth Information
Figure 10-14. A model using Table per Hierarchy inheritance with a derived type for each of the products
To map stored procedures to the Insert, Update, and Delete actions for this model, do the following:
1.
In your database, create the stored procedures in Listing 10-26. These stored procedures
will handle the Insert, Update, and Delete actions for the Book and DVD entities.
Listing 10-26. The Stored Procedure We Map to the Insert, Update, and Delete Actions for the Model
create procedure [chapter10].[InsertBook]
(@Title varchar(50), @Publisher varchar(50))
as
begin
insert into Chapter10.Product (Title, Publisher, ProductType) values
(@Title,@Publisher, 'Book')
select SCOPE_IDENTITY() as ProductId
end
go
create procedure [chapter10].[UpdateBook]
(@Title varchar(50), @Publisher varchar(50), @ProductId int)
as
begin
update Chapter10.Product set Title = @Title, Publisher = @Publisher
where ProductId = @ProductId
end
go
create procedure [chapter10].[DeleteBook]
(@ProductId int)
Search WWH ::




Custom Search