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)
passing parameter though query like using ?(optional parameter)
syama reddy
<p>Hi,</p>
<p> </p>
<p> This is Syam .Am working on Birt tool,Here I got one problem i.e. am passing parameter through query using ? .if i give one input value that time am getting out put .when i am passing null value that time am getting error</p>
<p> </p>
<p> </p>
<p>This is my query</p>
<p>
select if(? + INTERVAL a + b DAY in (select DATE_FORMAT(emp_attendance.date, '%Y-%m%-%d') from emp_attendance<br>
left join employee ON emp_attendance.employee_id = employee.id<br>
left join emp_type ON employee.emp_type_id = emp_type.id<br>
where month(emp_attendance.date)=?<br>
and year(emp_attendance.date)=?<br>
and <span style="color:#ff0000;">employee.id=?</span>),(select employee.id<br>
from emp_attendance<br>
left join employee ON emp_attendance.employee_id = employee.id<br>
left join emp_type ON employee.emp_type_id = emp_type.id<br>
where month(emp_attendance.date)=?<br>
and year(emp_attendance.date)=?<br><span style="color:#ff0000;">and employee.id=?</span><br>
and ? + INTERVAL a + b DAY in (DATE_FORMAT(emp_attendance.date,'%Y-%m%-%d'))),<span style="color:#ff0000;">?</span>) as empid<br>
FROM<br>
(SELECT 0 a UNION SELECT 1 a UNION SELECT 2 UNION SELECT 3<br>
UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7<br>
UNION SELECT 8 UNION SELECT 9 ) d,<br>
(SELECT 0 b UNION SELECT 10 UNION SELECT 20<br>
UNION SELECT 30 UNION SELECT 40) m<br>
WHERE ? + INTERVAL a + b DAY <= ( SELECT (select date(last_day(? + INTERVAL a DAY )) FROM<br>
(SELECT 0 a UNION SELECT 1 a UNION SELECT 2 UNION SELECT 3<br>
UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7<br>
UNION SELECT 8 UNION SELECT 9 ) d<br>
WHERE last_day(? + INTERVAL a DAY )<br>
group by last_day(? + INTERVAL a DAY )))<br>
ORDER BY a + b</p>
Find more posts tagged with
Comments
arya
<p>Hi,</p>
<p> This is arya, Am working on birt tool 2.5.2 .Here am getting one problem i.e. when i am passing one optional parameter through query using ? that time am getting error .if I pass one value am getting output but if I pass null value am getting error. below am sending my query.In main query am not using any tables</p>
<p><span style="font-size:18px;"><span style="font-family:arial, helvetica, sans-serif;"><span style="color:rgb(255,0,0);">(Here am passing empid .if i pass one empid am getting that particular empid details but when i am passing parameter as null value am not getting all empid details)</span></span></span></p>
<p> </p>
<p>
select if(? + INTERVAL a + b DAY in (select DATE_FORMAT(emp_attendance.date, '%Y-%m%-%d') from emp_attendance<br>
left join employee ON emp_attendance.employee_id = employee.id<br>
left join emp_type ON employee.emp_type_id = emp_type.id<br>
where month(emp_attendance.date)=?<br>
and year(emp_attendance.date)=?<br><span style="color:#ff0000;">and employee.id=?</span>),(select employee.id<br>
from emp_attendance<br>
left join employee ON emp_attendance.employee_id = employee.id<br>
left join emp_type ON employee.emp_type_id = emp_type.id<br>
where month(emp_attendance.date)=?<br>
and year(emp_attendance.date)=?<br><span style="color:#ff0000;">and employee.id=?</span><br>
and ? + INTERVAL a + b DAY in (DATE_FORMAT(emp_attendance.date,'%Y-%m%-%d'))),<span style="color:#ff0000;">?</span>) as empid<br>
FROM<br>
(SELECT 0 a UNION SELECT 1 a UNION SELECT 2 UNION SELECT 3<br>
UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7<br>
UNION SELECT 8 UNION SELECT 9 ) d,<br>
(SELECT 0 b UNION SELECT 10 UNION SELECT 20<br>
UNION SELECT 30 UNION SELECT 40) m<br>
WHERE ? + INTERVAL a + b DAY <= ( SELECT (select date(last_day(? + INTERVAL a DAY )) FROM<br>
(SELECT 0 a UNION SELECT 1 a UNION SELECT 2 UNION SELECT 3<br>
UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7<br>
UNION SELECT 8 UNION SELECT 9 ) d<br>
WHERE last_day(? + INTERVAL a DAY )<br>
group by last_day(? + INTERVAL a DAY )))<br>
ORDER BY a + b</p>
kclark
<p>If you're getting no results one way to solve this problem would be to check the value of your parameter in the beforeOpen of your data set. If the parameter is null then you can use</p>
<pre class="_prettyXprint">
this.queryText = "...";</pre>
<p>To reflect a query that doesn't use your parameter.</p>
<p> </p>
<p>If you're just getting an error can you post the stack?</p>