2

How can I conditionally include/exclude sections of text in my Word document based upon contents of the database, e.g. I want to do something like this in a Microsoft Word document (pseudo code):

IF <invantive:value-of expression="$P{Level}" /> GREATER THAN 3 THEN

TECHNICAL

Programming Languages

<invantive:foreach block="A.languages"><invantive:value-of expression="$F{technicalname}"/></invantive:foreach>

Operating Systems

<invantive:foreach block="B.systems"><invantive:value-of expression="$F{technicalname}"/></invantive:foreach>
END

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

0

You can do that the easiest way by putting the parameter check in a block. If possible, do that in the block that contains the data, or create an intermediate block to do so.

For example, put this in your query:

select ...
from   yourtable
where  $P{Level} > 3
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
0

When you want to exclude the whole piece of text starting with TECHNICAL and ending at END, you can also add an additional block in the model which either returns 0 or 1 rows.

Return 0 rows when the criterium is not met, return 1 row when it is met:

select 'ignore' from dual where <BOOLEAN EXPRESSION> 

Of course, you will need to replace dual by the corresponding singular table of the database platform used. On Oracle and Invantive SQL platforms, there is always a dual. On SQL Server you can skip the from dual. On other platforms, either create a table or query something known to only have one row, like a specific data dictionary table.

Then use the new block to create a nested foreach:

<invantive:foreach block="FILTERBLOCK">
TECHNICAL
Programming Languages
<invantive:foreach block="A.languages"><invantive:value-of expression="$F{technicalname}"/></invantive:foreach>
Operating Systems
<invantive:foreach block="B.systems"><invantive:value-of expression="$F{technicalname}"/></invantive:foreach>
</invantive:foreach>
Guido Leenders
  • 4,232
  • 1
  • 23
  • 43