Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to insert an extra row into the results of query?
millvall
Is there a way to insert an extra row into the results of a query?
REASON: I have a report parameter (List, drop down type) which is populated by a query. I want to insert a row to allow users to pick ALL accounts. eg: Parameter Text: "All Accounts" Parameter Value "%"
THINGS I?VE TRIED
- In the OnFetch event I thought I could alter column values as each row went thru.
If I could, I might be able to buffer the rows in an array and insert a new row, but no success.
dataSetRow["ACCTEXT"] = "All Accounts";
row["ACCTEXT"] = "All Accounts";
- THOUGHTS
- I could use a scripted data set to read an RDB table but that seems really clumsy.
Any suggestions welcome.
Thanks
Milton.
(OS BIRT 2.6.2)
Find more posts tagged with
Comments
Hans_vd
Hi,
You can add a "union all" to your SQL statement.
Regards
Hans
millvall
<blockquote class='ipsBlockquote' data-author="'Hans_vd'" data-cid="80493" data-time="1311530986" data-date="24 July 2011 - 11:09 AM"><p>
Hi,<br />
<br />
You can add a "union all" to your SQL statement.<br />
<br />
Regards<br />
Hans<br /></p></blockquote>
<br />
Hi Hans,<br />
Could you explain a little more. Below is the query used to populate the parameter.<br />
Text: CUSTOMERNAME<br />
Value: CUSTOMERNUMBER<br />
I want to insert <br />
Text: ALL CUSTOMERS<br />
Value: % <br />
How would I use a UNION ALL to do this.<br />
<br />
Many Thanks<br />
Milton.<br />
<br />
<br />
select CUSTOMERNAME, CUSTOMERNUMBER<br />
from CUSTOMERS<br />
order by CUSTOMERNAME
Hans_vd
The dataset for the report parameter would be like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select CUSTOMERNAME, CUSTOMERNUMBER
from CUSTOMERS
order by CUSTOMERNAME
union all
select 'All accounts' as customername, -1 customernumber
from dual</pre>
<br />
<br />
In the dataset that is used in the report you have to add an extra dataset parameter that is also bound to the report parameter and in the query you have to do something like this:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select ...
from table
where (field = ? or ? = -1)</pre>
<br />
<br />
Hope this helps<br />
Hans
millvall
<blockquote class='ipsBlockquote' data-author="'Hans_vd'" data-cid="80612" data-time="1311704249" data-date="26 July 2011 - 11:17 AM"><p>
The dataset for the report parameter would be like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select CUSTOMERNAME, CUSTOMERNUMBER
from CUSTOMERS
order by CUSTOMERNAME
union all
select 'All accounts' as customername, -1 customernumber
from dual</pre>
<br />
<br />
In the dataset that is used in the report you have to add an extra dataset parameter that is also bound to the report parameter and in the query you have to do something like this:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>select ...
from table
where (field = ? or ? = -1)</pre>
<br />
<br />
Hope this helps<br />
Hans<br /></p></blockquote>
<br />
=============================<br />
Hans,<br />
Thank You. It works great. My query below.<br />
I inserted a SPACE in front of ' All Customers' to force it to the top of the list.<br />
Then I added a few lines to Validate() on the parameter to convert -1 to % and all works great.<br />
Thanks again, Milt.<br />
<br />
select <br />
CUSTOMERNAME, <br />
CUSTOMERNUMBER<br />
from <br />
CUSTOMERS<br />
UNION<br />
select <br />
' All Customers' AS CUSTOMERNAME,<br />
-1 AS CUSTOMERNUMBER<br />
FROM CUSTOMERS