chrisssyp82
MIS
SQL 2008
Report Builder 3.0
Hi
This is probably going to be a stupid question.
I'm converting a load of Crystal Reports over into SSRS. All of the reports are based upon SQL stored proc's. I have this stored proc
However when this appears in SSRS, in my list of fields under the dataset all i have is section? Why is this? Will have to remove all of the error handling and debugging to allow the @Worktable fields to be shown?
Thanks
Report Builder 3.0
Hi
This is probably going to be a stupid question.
I'm converting a load of Crystal Reports over into SSRS. All of the reports are based upon SQL stored proc's. I have this stored proc
Code:
USE [InfoPortal]
GO
/****** Object: StoredProcedure [dbo].[usp_Report_MonthEnd_NAV] Script Date: 02/06/2012 16:50:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_Report_MonthEnd_NAV]
(
@RPT_TITL_NME NVARCHAR(40) = NULL
, @ORGID CHAR(4) = NULL
, @BKID CHAR(4) = NULL
, @ACCT_ID CHAR(12) = NULL
, @INQ_BASIS_NUM INT = NULL
, @CLS_SET_ID VARCHAR(15) = NULL
, @AS_OF_TMS VARCHAR(30) = NULL
, @ADJST_TMS VARCHAR(30) = NULL
, @ADJUST SMALLINT = NULL
, @START_DTE VARCHAR(30) = NULL
, @START_ADJDTE VARCHAR(30) = NULL
, @DTE_TYPE SMALLINT = NULL
, @INV_TYP_FLTR SMALLINT = NULL
, @TRN_TYP_NUM SMALLINT = NULL
, @MINMAXCODE SMALLINT = NULL
, @MINMAXVALUE FLOAT = NULL
, @INSTR_ID CHAR(16) = NULL
, @LDGR_NME VARCHAR(40) = NULL
, @APP_USR_ID CHAR(8) = NULL
, @SESSION_ID CHAR(50) = NULL
)
AS
BEGIN
SET NOCOUNT ON
/*------------------------------------------------------------------------------------------------------
Declare variables and worktable
------------------------------------------------------------------------------------------------------*/
DECLARE @Section VARCHAR(100)
DECLARE @ReportTitle VARCHAR(40)
DECLARE @EndDateTime DATETIME
DECLARE @LastWorkingDay DATETIME
DECLARE @Debug VARCHAR(1)
DECLARE @Worktable TABLE
(
[Portfolio ID] VARCHAR(12)
, [Date] DATETIME
, [All in Market Value] FLOAT
, [MID or BID] VARCHAR(3)
)
/*------------------------------------------------------------------------------------------------------
Set default values
------------------------------------------------------------------------------------------------------*/
SET @Section = 'Set default values'
BEGIN
/*SET @EndDateTime = DATEADD(s, -1, DATEADD(mm, DATEDIFF(mm, 0, GETDATE()),0)) --Defaults to end of last month 23:59:59
SET @LastWorkingDay = dbo.fn_GetLastWorkDay (@EndDateTime, 'GB')
SET @Debug = 'Y'
SELECT @EndDateTime AS EndDateTime, @LastWorkingDay AS LastWorkingDay*/ -- Removed to cater for report
SET @ReportTitle = ISNULL(NULLIF(@RPT_TITL_NME,''),'Month End NAV for Segregated Cash Clients')
SET @EndDateTime = ISNULL(CONVERT(DATETIME,NULLIF(@AS_OF_TMS,'')), DATEADD(s, -1, DATEADD(mm, DATEDIFF(mm, 0, GETDATE()),0)))--Defaults to end of last month 23:59:59
SET @LastWorkingDay = DBO.fn_GetLastWorkDay (@EndDateTime,'GB')
SET @Debug = ISNULL(NULLIF(@LDGR_NME,''),'N')
IF @LDGR_NME = 'TEST' SET @Debug = 'Y'
IF @@ERROR <> 0 GOTO Error_handler
IF @Debug = 'Y'
BEGIN
SELECT @Section AS Section
SELECT
@ReportTitle AS ReportTitle, @EndDateTime AS EndDateTime, @LastWorkingDay AS LastWorkingDay
END
END
/*------------------------------------------------------------------------------------------------------
Worktable
------------------------------------------------------------------------------------------------------*/
SET @Section = 'Worktable'
BEGIN
--Traded EOD BID, last working day
INSERT INTO @Worktable
SELECT
dgc.PortfolioID AS [Portfolio ID]
, @LastWorkingDay AS [Date]
, dgc.AcctMarketValue AS [All in Market Value]
, 'BID' AS [MID or BID]
FROM dbo.fn_Generic_DGControl ('', '', '$LCLAUTH_BID', 11, @LastWorkingDay, @LastWorkingDay, 'D', 'M', 'POSITION') AS dgc
/*INNER JOIN ivw_acct AS a
ON a.acct_id = dgc.PortfolioID
AND a.acct_id like 'R%' --local authority funds begin with R, except for the following...
AND a.acct_id NOT IN ('RCALCSHZ', 'RCALDERZ', 'RWELLCO', 'RWELLINV', 'RWELLSA')
AND a.acct_id NOT IN ('RDARLIN','RTTHORN') --Use traded EOD MID for these local authorities*/ -- Remove as Portfolio Group added to Netik Global
--Traded EOD MID, month end
INSERT INTO @Worktable
SELECT
dgc.PortfolioID AS [Portfolio ID]
, @EndDateTime AS [Date]
, dgc.AcctMarketValue AS [All in Market Value]
, 'MID' AS [MID or BID]
FROM dbo.fn_Generic_DGControl ('', '', '$LCLAUTH_MID', 1, @EndDateTime, @EndDateTime, 'D', 'M', 'POSITION') AS dgc
/*INNER JOIN ivw_acct AS a
ON a.acct_id = dgc.PortfolioID
AND a.acct_id IN ('RDARLIN','RTTHORN','RCHESHI2','IBROADDC')*/ -- Remove as Portfolio Group added to Netik Global
IF @@ERROR <> 0 GOTO Error_handler
IF @Debug = 'Y'
BEGIN
SELECT @Section AS Section
SELECT * FROM @Worktable ORDER BY [Portfolio ID]
END
END
/*------------------------------------------------------------------------------------------------------
Final Select
------------------------------------------------------------------------------------------------------*/
SET @Section = 'Final Select'
BEGIN
IF @Debug <> 'Y'
BEGIN
SELECT * FROM @Worktable
LEFT OUTER JOIN vw_report_rpt_def AS rrd
ON rrd.[Report Business Name] = @ReportTitle
END
IF @@ERROR <> 0 GOTO Error_handler
END
------------------------------------------------------------------------------------------------------
RETURN(0) -- Return success
/*------------------------------------------------------------------------------------------------------
Error handler
------------------------------------------------------------------------------------------------------*/
Error_handler:
DECLARE @errormsg varchar(400)
--Generate error message
SELECT @errormsg = 'Error occured at "' + @Section + '" in Stored Procedure ' + (SELECT name FROM sysobjects WHERE ID = @@PROCID)
--Raise error to the user
RAISERROR(@errormsg,16/*severity*/,1/*state*/)
--Return error indicator
RETURN (1)
END
However when this appears in SSRS, in my list of fields under the dataset all i have is section? Why is this? Will have to remove all of the error handling and debugging to allow the @Worktable fields to be shown?
Thanks