USP_COURSEACADEMICCATALOGDEPARTMENT_DELETE
Executes the "Course Academic Catalog Department Delete" record operation.
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | Input parameter indicating the ID of the record being deleted. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the delete. |
Definition
Copy
CREATE procedure dbo.USP_COURSEACADEMICCATALOGDEPARTMENT_DELETE
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier
)
as begin
--check deletion rules, if any
declare @COURSEID uniqueidentifier
declare @SELECTEDDEPARTMENTSCODE tinyint
select
@COURSEID = COURSE.ID,
@SELECTEDDEPARTMENTSCODE = COURSE.SELECTEDDEPARTMENTSCODE
from
dbo.COURSEACADEMICCATALOGDEPARTMENT
join dbo.COURSE on COURSEACADEMICCATALOGDEPARTMENT.COURSEID = COURSE.ID
where COURSEACADEMICCATALOGDEPARTMENT.ID = @ID
-- use the system generated delete routine to allow proper recording of the deleting agent
exec USP_COURSEACADEMICCATALOGDEPARTMENT_DELETEBYID_WITHCHANGEAGENTID @ID, @CHANGEAGENTID
-- selected departments code; check to see if course still has departments linked.
if @SELECTEDDEPARTMENTSCODE = 1
begin
if not exists(select ID from dbo.COURSEACADEMICCATALOGDEPARTMENT where COURSEID = @COURSEID)
raiserror('CK_COURSEDEPARTMENT_ATLEASTONEDEPARTMENT', 13, 1)
end
return 0;
end