USP_DATAFORMTEMPLATE_VIEW_BASIC_CLASS
The load procedure used by the view dataform template "Class Basic View Form"
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | IN | The input ID parameter used to load the fields defined on the form. |
@DATALOADED | bit | INOUT | Output parameter indicating whether or not data was actually loaded. |
@NAME | nvarchar(60) | INOUT | Name |
@SEATSAVAILABLE | int | INOUT | Seats available |
@FACULTY | nvarchar(1024) | INOUT | Faculty |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_BASIC_CLASS
(
@ID uniqueidentifier,
@DATALOADED bit = 0 output,
@NAME nvarchar(60) = null output,
@SEATSAVAILABLE int = null output,
@FACULTY nvarchar(1024) = null output
)
as
set nocount on;
-- be sure to set this, in case the select returns no rows
set @DATALOADED = 0;
declare @TARGETSIZE int
declare @NUMBERENROLLED int
-- populate the output parameters, which correspond to fields on the form. Note that
-- we set @DATALOADED = 1 to indicate that the load was successful. Otherwise, the system
-- will display a "no data loaded" message.
select @DATALOADED = 1,
@NAME = COURSE.[COURSEID] + ' - ' + CLASS.[SECTION],
@TARGETSIZE = CLASS.CLASSSIZETARGET,
@NUMBERENROLLED = dbo.UFN_CLASS_GETNUMBERENROLLED(CLASS.ID),
@SEATSAVAILABLE = 0,
@FACULTY = dbo.UFN_CLASS_GETFACULTYSTRING(CLASS.[ID])
from dbo.CLASS
inner join dbo.COURSE on dbo.CLASS.COURSEID = dbo.COURSE.ID
where dbo.CLASS.ID = @ID
if @DATALOADED = 1
begin
if @TARGETSIZE > @NUMBERENROLLED
begin
select @SEATSAVAILABLE = @TARGETSIZE - @NUMBERENROLLED
end
end
return 0;