USP_DATAFORMTEMPLATE_VIEW_SPONSORSHIPOPPORTUNITYINELIGIBLE
The load procedure used by the view dataform template "Sponsorship Opportunity Ineligible Preprocess 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. |
@ACTIVESPONSORSHIPS | smallint | INOUT | ACTIVESPONSORSHIPS |
@SPONSORSHIPOPPORTUNITYGROUPID | uniqueidentifier | INOUT | SPONSORSHIPOPPORTUNITYGROUPID |
@ISSOLESPONSORSHIP | bit | INOUT | ISSOLESPONSORSHIP |
@ELIGIBILITYCODE | smallint | INOUT | ELIGIBILITYCODE |
@SPONSORSHIPOPPORTUNITYTYPECODE | smallint | INOUT | SPONSORSHIPOPPORTUNITYTYPECODE |
@SPONSORSHIPREASONID | uniqueidentifier | INOUT | SPONSORSHIPREASONID |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_VIEW_SPONSORSHIPOPPORTUNITYINELIGIBLE
(
@ID uniqueidentifier,
@DATALOADED bit = 0 output,
@ACTIVESPONSORSHIPS smallint = null output,
@SPONSORSHIPOPPORTUNITYGROUPID uniqueidentifier = null output,
@ISSOLESPONSORSHIP bit = null output,
@ELIGIBILITYCODE smallint = null output,
@SPONSORSHIPOPPORTUNITYTYPECODE smallint = null output,
@SPONSORSHIPREASONID uniqueidentifier = null output
)
as
set nocount on;
-- be sure to set this, in case the select returns no rows
set @DATALOADED = 0;
-- 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,
@ELIGIBILITYCODE = ELIGIBILITYCODE,
@ACTIVESPONSORSHIPS = (select count(*)
from dbo.SPONSORSHIP
left outer join dbo.SPONSORSHIPTRANSACTION INITIATETRANSFERTRANSACTION on INITIATETRANSFERTRANSACTION.CONTEXTSPONSORSHIPID = SPONSORSHIP.ID and INITIATETRANSFERTRANSACTION.ACTIONCODE = 6
left outer join dbo.SPONSORSHIP PENDINGSPONSORSHIP on PENDINGSPONSORSHIP.ID = INITIATETRANSFERTRANSACTION.TARGETSPONSORSHIPID and PENDINGSPONSORSHIP.STATUSCODE = 0
where SPONSORSHIP.SPONSORSHIPOPPORTUNITYID = SPONSORSHIPOPPORTUNITY.ID
and SPONSORSHIP.STATUSCODE in(0,1)
and PENDINGSPONSORSHIP.ID is null),
@SPONSORSHIPOPPORTUNITYGROUPID = SPONSORSHIPOPPORTUNITYGROUPID,
@ISSOLESPONSORSHIP = (select count(*) from dbo.SPONSORSHIP where SPONSORSHIP.SPONSORSHIPOPPORTUNITYID = SPONSORSHIPOPPORTUNITY.ID and SPONSORSHIP.ISSOLESPONSORSHIP = 1 and SPONSORSHIP.STATUSCODE = 1),
@SPONSORSHIPREASONID = SPONSORSHIPREASONID,
@SPONSORSHIPOPPORTUNITYTYPECODE = SG.SPONSORSHIPOPPORTUNITYTYPECODE
from dbo.SPONSORSHIPOPPORTUNITY
inner join dbo.SPONSORSHIPOPPORTUNITYGROUP SG on SG.ID = SPONSORSHIPOPPORTUNITY.SPONSORSHIPOPPORTUNITYGROUPID
where SPONSORSHIPOPPORTUNITY.ID = @ID;
return 0;