I have a stored procedure which executes another stored procedure and uses those results in the final dataset being returned by my stored proc. Using Crystal 9 Report Designer, the report stalls when trying to access this stored proc. Does CR 9 have a problem w/stored procs when they have other embedded sp's? Any suggestions. Thanks
This is my stored proc:
-- ----------------------------------------------------------------------------
CREATE PROCEDURE
-- ----------------------------------------------------------------------------
sp_UIHODeclarations
-- ----------------------------------------------------------------------------
@Policy decimal(15, 0),
@PolicyVersion smallint
-- ----------------------------------------------------------------------------
AS
-- ----------------------------------------------------------------------------
DECLARE @Endorsements varchar(600)
-- ----------------------------------------------------------------------------
BEGIN
-- ----------------------------------------------------------------------------
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
-- ----------------------------------------------------------------------------
SELECT
-- ----------------------------------------------------------------------------
@Endorsements = T.Endorsements
-- ----------------------------------------------------------------------------
FROM
-- ----------------------------------------------------------------------------
UIHO T
-- ----------------------------------------------------------------------------
WHERE
-- ----------------------------------------------------------------------------
T.Id = @Policy AND
T.VersionNo = @PolicyVersion
-------------------------------------------------------------------------------
CREATE TABLE #Temp_UIHOEndorsements_ForDec (FormNo varchar(10), Premium decimal(11, 2))
-------------------------------------------------------------------------------
EXECUTE sp_UIHOEndorsements '#Temp_UIHOEndorsements_ForDec', @endorsements
-- ----------------------------------------------------------------------------
SELECT
-- ----------------------------------------------------------------------------
HO101 = MAX(CASE WHEN FormNo = 'HO101' THEN 'Y' ELSE 'N' END),
HO101Premium = MAX(CASE WHEN FormNo = 'HO101' THEN Premium ELSE 0 END),
HO105 = MAX(CASE WHEN FormNo = 'HO105' THEN 'Y' ELSE 'N' END),
HO105Premium = MAX(CASE WHEN FormNo = 'HO105' THEN Premium ELSE 0 END),
HO110 = MAX(CASE WHEN FormNo = 'HO110' THEN 'Y' ELSE 'N' END),
HO110Premium = MAX(CASE WHEN FormNo = 'HO110' THEN Premium ELSE 0 END),
HO112 = MAX(CASE WHEN FormNo = 'HO112' THEN 'Y' ELSE 'N' END),
HO112Premium = MAX(CASE WHEN FormNo = 'HO112' THEN Premium ELSE 0 END),
HO113 = MAX(CASE WHEN FormNo = 'HO113' THEN 'Y' ELSE 'N' END),
HO113Premium = MAX(CASE WHEN FormNo = 'HO113' THEN Premium ELSE 0 END),
HO120 = MAX(CASE WHEN FormNo = 'HO120' THEN 'Y' ELSE 'N' END),
HO120Premium = MAX(CASE WHEN FormNo = 'HO101' THEN Premium ELSE 0 END),
HO126 = MAX(CASE WHEN FormNo = 'HO126' THEN 'Y' ELSE 'N' END),
HO126Premium = MAX(CASE WHEN FormNo = 'HO126' THEN Premium ELSE 0 END),
HO140 = MAX(CASE WHEN FormNo = 'HO140' THEN 'Y' ELSE 'N' END),
HO140Premium = MAX(CASE WHEN FormNo = 'HO140' THEN Premium ELSE 0 END),
HO145 = MAX(CASE WHEN FormNo = 'HO145' THEN 'Y' ELSE 'N' END),
HO145Premium = MAX(CASE WHEN FormNo = 'HO145' THEN Premium ELSE 0 END),
HO160 = MAX(CASE WHEN FormNo = 'HO160' THEN 'Y' ELSE 'N' END),
HO160Premium = MAX(CASE WHEN FormNo = 'HO160' THEN Premium ELSE 0 END),
HO170 = MAX(CASE WHEN FormNo = 'HO170' THEN 'Y' ELSE 'N' END),
HO170Premium = MAX(CASE WHEN FormNo = 'HO170' THEN Premium ELSE 0 END),
HO201 = MAX(CASE WHEN FormNo = 'HO201' THEN 'Y' ELSE 'N' END),
HO201Premium = MAX(CASE WHEN FormNo = 'HO201' THEN Premium ELSE 0 END),
HO215 = MAX(CASE WHEN FormNo = 'HO215' THEN 'Y' ELSE 'N' END),
HO215Premium = MAX(CASE WHEN FormNo = 'HO215' THEN Premium ELSE 0 END),
HO225 = MAX(CASE WHEN FormNo = 'HO225' THEN 'Y' ELSE 'N' END),
HO225Premium = MAX(CASE WHEN FormNo = 'HO225' THEN Premium ELSE 0 END),
HO301 = MAX(CASE WHEN FormNo = 'HO301' THEN 'Y' ELSE 'N' END),
HO301Premium = MAX(CASE WHEN FormNo = 'HO301' THEN Premium ELSE 0 END),
HO330 = MAX(CASE WHEN FormNo = 'HO330' THEN 'Y' ELSE 'N' END),
HO330Premium = MAX(CASE WHEN FormNo = 'HO330' THEN Premium ELSE 0 END)
-- ----------------------------------------------------------------------------
INTO
-- ----------------------------------------------------------------------------
#Temp_Endorsements
-- ----------------------------------------------------------------------------
FROM
-- ----------------------------------------------------------------------------
#Temp_UIHOEndorsements_ForDec
-- ----------------------------------------------------------------------------
SELECT
-- ----------------------------------------------------------------------------
A.Id,
A.RealEffDate,
A.renewalOfPolicyNo,
A.name,
Address = REPLACE(A.Address,'##',' '),
A.lot,
A.block,
A.addition,
A.ChangeType,
A.city,
A.county,
A.state,
A.zipCode,
MailingAddress = REPLACE(A.mailingAddress,'##',' '),
A.mailingCity,
A.mailingState,
A.mailingZipCode,
PolicyType =
(CASE PolicyType
WHEN '1' THEN 'HO-A'
WHEN '2' THEN 'HO-B'
WHEN '3' THEN 'HO-C'
WHEN '4' THEN 'HO-BT'
WHEN '5' THEN 'HO-CT'
WHEN '6' THEN 'HO-CONB'
WHEN '7' THEN 'HO-CONC'
ELSE: ''
END),
A.ReferenceNo,
A.uarCoverageEffDate,
A.uarCoverageExpDate,
A.RatingTerritory,
ProtectionClass,
A.constructionType,
A.yearBuilt,
A.roofType,
A.cityLimit,
A.dwelling,
A.otherStructures,
PersonalProperty,
PersonalPropertyOffPremises,
A.liability,
A.medicalPayments,
A.ded1,
A.ded1Amount,
A.ded2,
A.ded2Amount,
--A.additionalResidencePremium,
A.basePremium,
A.basicPremium,
A.standardPremium,
ProtectionConstructionFactor,
A.amountOfInsuranceFactor,
FlexFactor,
A.ded1Factor,
A.ded2Factor,
A.HO101Factor,
A.HO140Factor,
A.HO145Rate,
A.HO330Rate,
A.dwellingECPremium,
A.dwellingECMultiplier,
PersonalPropertyECPremium,
PersonalPropertyECMultiplier,
LiabilityBasePremium = A.LiabilityBasePremiumMainDwelling,
A.otherStructuresPremiumRate,
A.lossOfUse,
FireSmokeAlarmType,
A.alarmRate,
A.AutomaticSprinklerSystem,
A.AutomaticSprinklerSystemRate,
A.AutomaticSprinklerSystemCT,
A.AutomaticSprinklerSystemCTRate,
A.HomeSecurityDevice,
A.HomeSecurityDeviceRate,
A.HomeSecurityDeviceS6A1,
A.HomeSecurityDeviceS6A1Rate,
A.HomeSecurityDeviceS6A2,
A.HomeSecurityDeviceS6A2Rate,
FireExtinguisher,
FireExtinguisherRate,
A.AgeOfRisk,
A.AgeOfRiskRate,
A.NonCombustibleRoof,
A.NonCombustibleRoofRate,
A.CareAndConditionOfPremises,
A.CareAndConditionOfPremisesRate,
A.LossExperienceCredit,
A.LossExperienceCreditRate,
A.CompanionPolicy,
A.CompanionPolicyRate,
FullReplacementCost,
FullReplacementCostRate,
A.SeniorCitizen,
A.SeniorCitizenRate,
A.DryHydrant,
A.DryHydrantRate,
PropertyPermanentMarking,
PropertyPermanentMarkingRate,
A.StoveTopFireSupression,
A.StoveTopFireSupressionRate,
A.TotalPremium,
A.additionalInformation,
A.Endorsements,
AgentName = B.name,
AgentCode = B.code,
AgentAddress = REPLACE(B.MailingAddress,'##',' '),
AgentCity = B.mailingCity,
AgentState = B.mailingState,
AgentZipCode = B.mailingZipCode,
AgentPhone = B.daytimePhone,
E.TransactionEffDate,
E.TransactionName,
Z.HO101,
Z.HO101Premium,
Z.HO105,
Z.HO105Premium,
Z.HO110,
Z.HO110Premium,
Z.HO112,
Z.HO112Premium,
Z.HO113,
Z.HO113Premium,
Z.HO120,
Z.HO120Premium,
Z.HO126,
Z.HO126Premium,
Z.HO140,
Z.HO140Premium,
Z.HO145,
Z.HO145Premium,
Z.HO160,
Z.HO160Premium,
Z.HO170,
Z.HO170Premium,
Z.HO201,
Z.HO201Premium,
Z.HO215,
Z.HO215Premium,
Z.HO225,
Z.HO225Premium,
Z.HO301,
Z.HO301Premium,
Z.HO330,
Z.HO330Premium
-- ----------------------------------------------------------------------------
FROM
-- ----------------------------------------------------------------------------
UIHO A,
Agent B,
Event E,
ObjectManager O,
#Temp_Endorsements Z
-- ----------------------------------------------------------------------------
WHERE
-- ----------------------------------------------------------------------------
A.Id = @Policy AND
A.VersionNo = @PolicyVersion AND
A.Agent = B.Id AND
B.Id = O.Id AND
B.VersionNo = O.CurrentVersionNo AND
A.Id = E.Id AND
A.EventNo = E.No
-- ----------------------------------------------------------------------------
RETURN @@ROWCOUNT
-- ----------------------------------------------------------------------------
END
This is my stored proc:
-- ----------------------------------------------------------------------------
CREATE PROCEDURE
-- ----------------------------------------------------------------------------
sp_UIHODeclarations
-- ----------------------------------------------------------------------------
@Policy decimal(15, 0),
@PolicyVersion smallint
-- ----------------------------------------------------------------------------
AS
-- ----------------------------------------------------------------------------
DECLARE @Endorsements varchar(600)
-- ----------------------------------------------------------------------------
BEGIN
-- ----------------------------------------------------------------------------
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
-- ----------------------------------------------------------------------------
SELECT
-- ----------------------------------------------------------------------------
@Endorsements = T.Endorsements
-- ----------------------------------------------------------------------------
FROM
-- ----------------------------------------------------------------------------
UIHO T
-- ----------------------------------------------------------------------------
WHERE
-- ----------------------------------------------------------------------------
T.Id = @Policy AND
T.VersionNo = @PolicyVersion
-------------------------------------------------------------------------------
CREATE TABLE #Temp_UIHOEndorsements_ForDec (FormNo varchar(10), Premium decimal(11, 2))
-------------------------------------------------------------------------------
EXECUTE sp_UIHOEndorsements '#Temp_UIHOEndorsements_ForDec', @endorsements
-- ----------------------------------------------------------------------------
SELECT
-- ----------------------------------------------------------------------------
HO101 = MAX(CASE WHEN FormNo = 'HO101' THEN 'Y' ELSE 'N' END),
HO101Premium = MAX(CASE WHEN FormNo = 'HO101' THEN Premium ELSE 0 END),
HO105 = MAX(CASE WHEN FormNo = 'HO105' THEN 'Y' ELSE 'N' END),
HO105Premium = MAX(CASE WHEN FormNo = 'HO105' THEN Premium ELSE 0 END),
HO110 = MAX(CASE WHEN FormNo = 'HO110' THEN 'Y' ELSE 'N' END),
HO110Premium = MAX(CASE WHEN FormNo = 'HO110' THEN Premium ELSE 0 END),
HO112 = MAX(CASE WHEN FormNo = 'HO112' THEN 'Y' ELSE 'N' END),
HO112Premium = MAX(CASE WHEN FormNo = 'HO112' THEN Premium ELSE 0 END),
HO113 = MAX(CASE WHEN FormNo = 'HO113' THEN 'Y' ELSE 'N' END),
HO113Premium = MAX(CASE WHEN FormNo = 'HO113' THEN Premium ELSE 0 END),
HO120 = MAX(CASE WHEN FormNo = 'HO120' THEN 'Y' ELSE 'N' END),
HO120Premium = MAX(CASE WHEN FormNo = 'HO101' THEN Premium ELSE 0 END),
HO126 = MAX(CASE WHEN FormNo = 'HO126' THEN 'Y' ELSE 'N' END),
HO126Premium = MAX(CASE WHEN FormNo = 'HO126' THEN Premium ELSE 0 END),
HO140 = MAX(CASE WHEN FormNo = 'HO140' THEN 'Y' ELSE 'N' END),
HO140Premium = MAX(CASE WHEN FormNo = 'HO140' THEN Premium ELSE 0 END),
HO145 = MAX(CASE WHEN FormNo = 'HO145' THEN 'Y' ELSE 'N' END),
HO145Premium = MAX(CASE WHEN FormNo = 'HO145' THEN Premium ELSE 0 END),
HO160 = MAX(CASE WHEN FormNo = 'HO160' THEN 'Y' ELSE 'N' END),
HO160Premium = MAX(CASE WHEN FormNo = 'HO160' THEN Premium ELSE 0 END),
HO170 = MAX(CASE WHEN FormNo = 'HO170' THEN 'Y' ELSE 'N' END),
HO170Premium = MAX(CASE WHEN FormNo = 'HO170' THEN Premium ELSE 0 END),
HO201 = MAX(CASE WHEN FormNo = 'HO201' THEN 'Y' ELSE 'N' END),
HO201Premium = MAX(CASE WHEN FormNo = 'HO201' THEN Premium ELSE 0 END),
HO215 = MAX(CASE WHEN FormNo = 'HO215' THEN 'Y' ELSE 'N' END),
HO215Premium = MAX(CASE WHEN FormNo = 'HO215' THEN Premium ELSE 0 END),
HO225 = MAX(CASE WHEN FormNo = 'HO225' THEN 'Y' ELSE 'N' END),
HO225Premium = MAX(CASE WHEN FormNo = 'HO225' THEN Premium ELSE 0 END),
HO301 = MAX(CASE WHEN FormNo = 'HO301' THEN 'Y' ELSE 'N' END),
HO301Premium = MAX(CASE WHEN FormNo = 'HO301' THEN Premium ELSE 0 END),
HO330 = MAX(CASE WHEN FormNo = 'HO330' THEN 'Y' ELSE 'N' END),
HO330Premium = MAX(CASE WHEN FormNo = 'HO330' THEN Premium ELSE 0 END)
-- ----------------------------------------------------------------------------
INTO
-- ----------------------------------------------------------------------------
#Temp_Endorsements
-- ----------------------------------------------------------------------------
FROM
-- ----------------------------------------------------------------------------
#Temp_UIHOEndorsements_ForDec
-- ----------------------------------------------------------------------------
SELECT
-- ----------------------------------------------------------------------------
A.Id,
A.RealEffDate,
A.renewalOfPolicyNo,
A.name,
Address = REPLACE(A.Address,'##',' '),
A.lot,
A.block,
A.addition,
A.ChangeType,
A.city,
A.county,
A.state,
A.zipCode,
MailingAddress = REPLACE(A.mailingAddress,'##',' '),
A.mailingCity,
A.mailingState,
A.mailingZipCode,
PolicyType =
(CASE PolicyType
WHEN '1' THEN 'HO-A'
WHEN '2' THEN 'HO-B'
WHEN '3' THEN 'HO-C'
WHEN '4' THEN 'HO-BT'
WHEN '5' THEN 'HO-CT'
WHEN '6' THEN 'HO-CONB'
WHEN '7' THEN 'HO-CONC'
ELSE: ''
END),
A.ReferenceNo,
A.uarCoverageEffDate,
A.uarCoverageExpDate,
A.RatingTerritory,
ProtectionClass,
A.constructionType,
A.yearBuilt,
A.roofType,
A.cityLimit,
A.dwelling,
A.otherStructures,
PersonalProperty,
PersonalPropertyOffPremises,
A.liability,
A.medicalPayments,
A.ded1,
A.ded1Amount,
A.ded2,
A.ded2Amount,
--A.additionalResidencePremium,
A.basePremium,
A.basicPremium,
A.standardPremium,
ProtectionConstructionFactor,
A.amountOfInsuranceFactor,
FlexFactor,
A.ded1Factor,
A.ded2Factor,
A.HO101Factor,
A.HO140Factor,
A.HO145Rate,
A.HO330Rate,
A.dwellingECPremium,
A.dwellingECMultiplier,
PersonalPropertyECPremium,
PersonalPropertyECMultiplier,
LiabilityBasePremium = A.LiabilityBasePremiumMainDwelling,
A.otherStructuresPremiumRate,
A.lossOfUse,
FireSmokeAlarmType,
A.alarmRate,
A.AutomaticSprinklerSystem,
A.AutomaticSprinklerSystemRate,
A.AutomaticSprinklerSystemCT,
A.AutomaticSprinklerSystemCTRate,
A.HomeSecurityDevice,
A.HomeSecurityDeviceRate,
A.HomeSecurityDeviceS6A1,
A.HomeSecurityDeviceS6A1Rate,
A.HomeSecurityDeviceS6A2,
A.HomeSecurityDeviceS6A2Rate,
FireExtinguisher,
FireExtinguisherRate,
A.AgeOfRisk,
A.AgeOfRiskRate,
A.NonCombustibleRoof,
A.NonCombustibleRoofRate,
A.CareAndConditionOfPremises,
A.CareAndConditionOfPremisesRate,
A.LossExperienceCredit,
A.LossExperienceCreditRate,
A.CompanionPolicy,
A.CompanionPolicyRate,
FullReplacementCost,
FullReplacementCostRate,
A.SeniorCitizen,
A.SeniorCitizenRate,
A.DryHydrant,
A.DryHydrantRate,
PropertyPermanentMarking,
PropertyPermanentMarkingRate,
A.StoveTopFireSupression,
A.StoveTopFireSupressionRate,
A.TotalPremium,
A.additionalInformation,
A.Endorsements,
AgentName = B.name,
AgentCode = B.code,
AgentAddress = REPLACE(B.MailingAddress,'##',' '),
AgentCity = B.mailingCity,
AgentState = B.mailingState,
AgentZipCode = B.mailingZipCode,
AgentPhone = B.daytimePhone,
E.TransactionEffDate,
E.TransactionName,
Z.HO101,
Z.HO101Premium,
Z.HO105,
Z.HO105Premium,
Z.HO110,
Z.HO110Premium,
Z.HO112,
Z.HO112Premium,
Z.HO113,
Z.HO113Premium,
Z.HO120,
Z.HO120Premium,
Z.HO126,
Z.HO126Premium,
Z.HO140,
Z.HO140Premium,
Z.HO145,
Z.HO145Premium,
Z.HO160,
Z.HO160Premium,
Z.HO170,
Z.HO170Premium,
Z.HO201,
Z.HO201Premium,
Z.HO215,
Z.HO215Premium,
Z.HO225,
Z.HO225Premium,
Z.HO301,
Z.HO301Premium,
Z.HO330,
Z.HO330Premium
-- ----------------------------------------------------------------------------
FROM
-- ----------------------------------------------------------------------------
UIHO A,
Agent B,
Event E,
ObjectManager O,
#Temp_Endorsements Z
-- ----------------------------------------------------------------------------
WHERE
-- ----------------------------------------------------------------------------
A.Id = @Policy AND
A.VersionNo = @PolicyVersion AND
A.Agent = B.Id AND
B.Id = O.Id AND
B.VersionNo = O.CurrentVersionNo AND
A.Id = E.Id AND
A.EventNo = E.No
-- ----------------------------------------------------------------------------
RETURN @@ROWCOUNT
-- ----------------------------------------------------------------------------
END