Alter Procedure WG_NEWS_INSERTCATEGORY
@Name varchar (50), @ Description Varchar (250), @ imageurl varchar (250), @ categoryid int outprutasdeclare @Currid Int
- See eti the category alleady exists
Select @currid = categoryid from news_categories where name = @Name
- IF not, add it
IF @CurrID IS NULL BEGIN INSERT INTO News_Categories (Name, Description, ImageUrl) VALUES (@Name, @Description, @ImageUrl) SET @CategoryID = @@ IDENTITY IF @@ ERROR> 0 BEGIN RAISERROR ( 'Insert of Category failed', 16, 1) RETURN 99 EndElse Begin Set @categoryId = -1 End