如果存在相同类型相同名称的记录则不能添加
CREATE proc QsqPageContentInsertUpdateDel
(
@id int=0 out ,
@ObjectID int=null,
@Type varchar(50)=null,
@ShowType varchar(50)=null,
@ShowName varchar(500)=null,
@OrderBy int=null,
@action int=0 --1 insert 2 update 3delete
)
AS
IF @action = 1
BEGIN
if not exists (select * from QsqPageContent where ObjectID=@ObjectID and ShowType=@ShowType)
begin
INSERT INTO QsqPageContent(
[ObjectID],[Type],[ShowType],[ShowName],[OrderBy]
)VALUES(
@ObjectID,@Type,@ShowType,@ShowName,@OrderBy
)
SET @id = @@IDENTITY
end
END
else if @action = 2
BEGIN
UPDATE QsqPageContent SET
[ShowName] = @ShowName,[OrderBy] = @OrderBy
WHERE ID=@id
END
else if @action = 3
BEGIN
DELETE QsqPageContent
WHERE ID=@id
END
GO
(
@id int=0 out ,
@ObjectID int=null,
@Type varchar(50)=null,
@ShowType varchar(50)=null,
@ShowName varchar(500)=null,
@OrderBy int=null,
@action int=0 --1 insert 2 update 3delete
)
AS
IF @action = 1
BEGIN
if not exists (select * from QsqPageContent where ObjectID=@ObjectID and ShowType=@ShowType)
begin
INSERT INTO QsqPageContent(
[ObjectID],[Type],[ShowType],[ShowName],[OrderBy]
)VALUES(
@ObjectID,@Type,@ShowType,@ShowName,@OrderBy
)
SET @id = @@IDENTITY
end
END
else if @action = 2
BEGIN
UPDATE QsqPageContent SET
[ShowName] = @ShowName,[OrderBy] = @OrderBy
WHERE ID=@id
END
else if @action = 3
BEGIN
DELETE QsqPageContent
WHERE ID=@id
END
GO