Quantcast
Channel: Parameters SSRS
Viewing all articles
Browse latest Browse all 36

Parameters SSRS

$
0
0

This is the logic in the reportprocedure that get the parameter-values from the promptprocedures:

alter

 

procedure [dbo].[rp4DeparturesTst]

@Line

nvarchar(8),

@LineDirectionCode

nvarchar(7),

@DepartureJourneyPatternID

bigint,

@DepartureTimetablePeriodCode

nvarchar(50),

@DayGroupKey

int,

@TimeIntervalKey

int,

@DateInterval1Start

char(10),

@DateInterval1End

char(10),

@TimeInterval1Start

char(5),

@TimeInterval1End

char(5),

@DateInterval2Start

char(10),

@DateInterval2End

char(10),

@username

char(20)

 

as

begin

-----------------create dateperiodname

set

 

nocounton

declare

 

@tmp22 nvarchar(80)

select

 

@tmp22 =

convert

 

(nvarchar(10),min(d.DepartureTimeTablePeriodStartDate), 120)+' - '+

convert

 

(nvarchar(10),max(d.DepartureTimeTablePeriodEndDate), 120)+' Period: '+ DepartureTimetablePeriodCode

 

FROM dbo.DimDeparture d

 

INNERJOIN dbo.DimDayGroup dg

 

ON d.DepartureDayTypeCodebetween dg.DayTypeStartand dg.DaytypeEnd

 

INNERJOIN dbo.utlContractorAccessLine cal

 

ON d.DepartureLineNumber= cal.Line

 

AND d.DepartureTimeTablePeriodCode= cal.PeriodCode

 

WHERE d.DepartureLineNumber= @line

 

AND d.RowIsCurrent='Y'

 

AND dg.DayGroupKey= @daygroupKey

and

 

d.DepartureTimeTablePeriodCode= @DepartureTimetablePeriodCode

GROUP

 

BY d.DepartureTimetablePeriodCode

 

--ORDER BY 1,2

if

 

exists

(

 

select [user_name]from dbo.save_paramswhere [user_name]= @username)

update

 

save_params

set

 

DatePeriodName =@tmp22, line = @line, daygroup = @daygroupKey

where

 

[user_name] = @username

else

 

insert save_paramsvalues(@line,@daygroupKey,@username,@tmp22, 0)

when I put the insert/update in the beginning like here the DateperiodName gets a Null-value although when I show the value of @tmp22 it shows the value I expect (?) When i Put it in the end of the procedure it just ignores the insert/update but shows the correct value of @tmp22. I didn't paste all the code, it's a bit to long.

Here is on of the prompt-procedures that should show the saved parameter as a default-value:

USE

 

[RUST]

GO

/****** Object: StoredProcedure [dbo].[rpDepartureLinesPrompt] Script Date: 02/02/2011 13:13:29 ******/

SET

 

ANSI_NULLSON

GO

SET

 

QUOTED_IDENTIFIERON

GO

-- ================================================================================

-- Author: Pontus Carsall, Christer Storgrd

-- Create date: 2008-08-07

-- Description: Dropdownprompt for departure lines (Linjer)

-- Modification: 2008-09-04 PC, shortened DepartureLineName and

-- created table utlDepartureLinesPrompt

-- 2008-09-09 AJ, Added order by DepartureLineNumber.

-- 2008-11-19 PC, Added logic for contractor access

-- 2010-12-02 AL Added logic to retrieve saved parameters

-- =================================================================================

ALTER

 

procedure [dbo].[rpDepartureLinesPrompt]

@UserName

NVARCHAR(50)

 

AS

BEGIN

SET

 

NOCOUNTON;

 

/*select DepartureLineNumber, DepartureLineName

from dbo.utlDepartureLinesPrompt

order by convert(int, DepartureLineNumber)*/

 

 

DECLARE @ContractorNVARCHAR(50)

 

DECLARE @AllAccessContractorNVARCHAR(10)

 

SET @AllAccessContractor='SL';

 

-- get Contractor the UserName belongs to

 

SELECT @Contractor= Contractor

 

FROM dbo.utlContractorAccessUserwith(nolock)

 

WHERE UserName= @UserName

 

-- return Lines depending on access rights

IF

 

@Contractor = @AllAccessContractor

Begin

--Get saved parameter if any

if

 

exists(select [user_name]from save_paramswhere [user_name]= @UserName)

--begin

select

 

distinct utlDepartureLinesPrompt.DepartureLineName,

DepartureLineNumber

,

save_params

.first_rowfrom save_params

inner

 

join dbo.utlDepartureLinesPrompton save_params.line=

utlDepartureLinesPrompt

.DepartureLineNumberwhere [user_name]= @UserName

union

 

-- to retrieve the original list

select

 

DepartureLineName,DepartureLinenumber,DepartureLinenumberas first_row

FROM

 

dbo.utlDepartureLinesPrompt dwith(nolock)

ORDER

 

BY first_row

else

 

 

SELECTDISTINCT d.DepartureLineNumber, d.DepartureLineName

 

FROM dbo.utlDepartureLinesPrompt d with(nolock)

 

INNERJOIN dbo.utlContractorAccessLine cal with(nolock)ON d.DepartureLineNumber= cal.Line

 

--WHERE cal.Contractor = @Contractor

 

ORDERBYCONVERT(INT, d.DepartureLineNumber)

 

 

 

 

 

END

END

 


anniqa_2

Viewing all articles
Browse latest Browse all 36

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>