The Community_Faqs Stored Procedures
The next steps in our blueprint calls for us to create stored procedures to add an FAQ, edit an FAQ, retrieve a single FAQ, and retrieve a paged and sorted list of FAQs, for a total of four procedures. All of the data access in the CSK happens via stored procedures. There is no ad hoc SQL in the code, which is a good practice from both encapsulation and security standpoints. The first procedure we will write is to add new FAQ content.
Community_FaqsAddFaq
The stored procedure for adding a new FAQ to the database is shown now. We do not need to provide a parameter for every column in the two content tables. For example, we do not need to pass a parameter to populate the contentPage_ViewCount
column. Many of the columns contain a sensible default value (contentPage_ViewCount
defaults to 0
) or allow NULL
values (contentPage_dateCommented
) for new content.
CREATE PROCEDURE Community_FaqsAddFaq ( @communityID int, @sectionID int, @username nvarchar(50), @topicID...