using checkbox values in the where clause [message #77970] |
Thu, 27 December 2001 08:15 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Ramaa
Messages: 7 Registered: December 2001
|
Junior Member |
|
|
Hello,
I am trying to run a report from form. The forms has checkboxes. I assign a value to the checkbox when it is checked. What I would want to do is when the checkbox is checked, the value in the checkbox should go into the where clause of the SQL statement. I have many checkboxes. So all those which are checked should go into the where clause of the query.
For e.g. if I have ten diseases, I can check more than one disease. The SQL statement should be like:
select patients from patients_table where disease in (disease1, disease2, etc.). disease1, disease2, etc. are the checkboxes checked. I want to pull out the patient details in a Report.
I could pull out the details if only one checkbox is checked. Can anyone tell me how I should do if multiple checkboxes are checked?
Thank You for your help.
Rama.
----------------------------------------------------------------------
|
|
|
Re: using checkbox values in the where clause [message #77971 is a reply to message #77970] |
Thu, 27 December 2001 08:35 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Shilpa
Messages: 59 Registered: November 2001
|
Member |
|
|
In the form check each checkbox for whether it is checked or not.
for eg: The checkboxes are named d1..d10. They have a value Y if checked.
Declare
temp varchar2(2000);
begin
if :control.d1 = 'Y' then
if temp is null then
temp := :control.d1;
else
temp := temp ||','||:control.d1;
end if;
end if;
if :control.d2 = 'Y' then
if temp is null then
temp := :control.d1;
else
temp := temp ||','||:control.d2;
end if;
end if;
......
......
if :control.d10 = 'Y' then
if temp is null then
temp := :control.d1;
else
temp := temp ||','||:control.d10;
end if;
end if;
temp := 'where disease in ('||temp||')';
-- send this temp as a parameter to the report
end;
In the report:
create a parameter named temp of varchar2(2000)
Query:
select patients from patients_table||:temp;
----------------------------------------------------------------------
|
|
|
Re: using checkbox values in the where clause [message #78011 is a reply to message #77970] |
Thu, 03 January 2002 13:29 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
Ramaa
Messages: 7 Registered: December 2001
|
Junior Member |
|
|
Thank You Shilpa. It worked when I checked more than one checkbox and was able to query with the values checked in the checkbox in the where clause.
----------------------------------------------------------------------
|
|
|