Reporting Stored Procedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to adapt a Stored Procedure like the following for reporting purposes.
select
frmInstId,
frmName,
frmDueDate,
country,
description,
frmLastStatus
flgStat1,
flgStat2,
flgStat3,
flgStat4,
flgStat5
FROM
tblFrmDef,
tblFrmInst,
tblFrmHist,
tblObjects
WHERE
tblFrmDef.frmDefId = tblFrmInst.frmDefId and
tblFrmInst.objId = tblObjects.objId and
tblFrmInst.frmInstId = tblFrmHist.frmInstId and
tblFrmInst.flgActive=1


The problem is that the report can potentially take numerous permutations of
numerous parameters, including:
-tblFrmInst.frmDueDate (range possible)
-tblObjects.user
-tblFrmInst.flgActive (1 or 0)
-tblDef.frmName,
-tblFrmHist.frmLastStatus,
-flgStat1,
-flgStat2,
-flgStat3,
-flgStat4
-flgStat5

Short of building a heavily nested if...then...else statement to build the
correct select statement, are there any better ideas?
 
Patrick:

If all of those values at the bottom are paramaters, you can do this:

Where...

FieldName = @ParameterName OR @ParameterName = Null

Doing that for each of the values in question.

If I'm misunderstanding you though and you need different fields to show up,
then you will need to nest the ifs in all likelihood or, depending on the
reporting tool you're using, hide the fields based on whatever logic you are
employing to make these determinations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top