ENGR024
ENGR024

Reputation: 317

SSRS Error using Common Value Expressions

I am getting the following below error in my query when I run the SSRS report. When I test it in the query designer and I manually enter the parameters, I get the results fine. But when I run it I get the following error:

"Parameter validation failed. It is not possible to provide valid values for all parameters. (rsParameterError)".

The parameters I am entering manually in the Query designer are @FilterByEventCode, @FQN, @DateStart, @DateStop.

I put all my my parameters to 'always refresh' and even tried the automatic mode but i still get this error.

Any ideas? Your help is most appreciated.

IF @FilterByEventCode IS NULL 
  BEGIN 
      SELECT * 
      FROM   dbo.Historywithqualityfilter(@FQN, '.Event Code,.Event Description' 
             , 
                    Dateadd(mi, -10, @DateStart), @DateStop, 'good', 'KLN-FTVP') 
  END 
ELSE 
  BEGIN 
      WITH t1(timestamp, eventcode) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Code', 
                      Dateadd(mi, -10, @DateStart), 
                              @DateStop, 'good', 'KLN-FTVP') 
               WHERE  @FilterByEventCode = valueasstring), 
           t2(timestamp, eventdescription) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Description', 
                              Dateadd(mi, -10, @DateStart), @DateStop, 'good', 
                      'KLN-FTVP')) 
      SELECT * 
      FROM   t1 a 
             INNER JOIN t2 b 
                     ON a.timestamp = b.timestamp 
  END 

Upvotes: 0

Views: 170

Answers (1)

ENGR024
ENGR024

Reputation: 317

I had to add the cte's in the first part of my query in order to the fields to appear thus preventing the error.

IF @FilterByEventCode IS NULL 
  BEGIN 
     WITH t1(timestamp, eventcode) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Code', 
                      Dateadd(mi, -10, @DateStart), 
                              @DateStop, 'good', 'KLN-FTVP') 
               WHERE  @FilterByEventCode is null), 
           t2(timestamp, eventdescription) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Description', 
                              Dateadd(mi, -10, @DateStart), @DateStop, 'good', 
                      'KLN-FTVP')) 
      SELECT * 
      FROM   t1 a 
             INNER JOIN t2 b 
                     ON a.timestamp = b.timestamp  
  END 
ELSE 
  BEGIN 
      WITH t1(timestamp, eventcode) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Code', 
                      Dateadd(mi, -10, @DateStart), 
                              @DateStop, 'good', 'KLN-FTVP') 
               WHERE  @FilterByEventCode = valueasstring), 
           t2(timestamp, eventdescription) 
           AS (SELECT localtimestamp, 
                      valueasstring 
               FROM   dbo.Historywithqualityfilter (@FQN, '.Event Description', 
                              Dateadd(mi, -10, @DateStart), @DateStop, 'good', 
                      'KLN-FTVP')) 
      SELECT * 
      FROM   t1 a 
             INNER JOIN t2 b 
                     ON a.timestamp = b.timestamp 
  END

Upvotes: 0

Related Questions