Home » Developer & Programmer » Forms » dynamic selection of records based on checkbox checked
dynamic selection of records based on checkbox checked [message #78028] Fri, 04 January 2002 11:20 Go to next message
Rama
Messages: 17
Registered: October 2001
Junior Member
Hello,
I want to select a list of records from a multirecord block by using the checkbox checked values as the criterion and use the records selected in the where clause for querying in another forms. The data from the multirecord block is from a query result and hence is dynamic.

I went about doing this:
I created a multirecord block. In the multirecord block, I created a checkbox which was a non-database item.
In the when_button_pressed trigger I wrote the following code:
declare
temp varchar2(1000);
start_rec number;
stop_rec number;
item_id item;
block_id block;
item_value varchar2(1000);
pl_id paramlist;
item_name varchar2(10);
patient_list varchar2(1000);
begin
go_block('patient_list');
block_id:=find_block('patient_list');
start_rec:=1;
stop_rec:=get_block_property(block_id,query_hits);
for i in start_rec..stop_rec loop
if :selection='Y' then --selection is the checkbox
if item_value is null then
/*item_value holds the value of the data shown in the forms & for which the checkbox is checked*/
item_value:=name_in(':patient_list.patient_id');
/*patient_id is the item name as well as field name in the table*/
else
item_value:=item_value||','||name_in(':patient_list.patient_id');
end if;
end if;
end loop;
patient_list:='('||item_value||')';
pl_id:=create_parameter_list('list_of_patients');
add_parameter(pl_id,'querypatients',text_parameter,patient_list);
message(patientlist);
run_product
(forms,'patient_history',synchronous,runtime,filesystem,pl_id,null);
end;

When I run this form, patient_list comes as
(111,111,111,111,111,111,111) where 111 is the value of the patient_id.
The only value that gets into the patient_list is the patient_id for the last checkbox I have checked in the forms and the same patient_id appears so many
times.

Can anyone tell me where I am doing the mistake? Why is the same value appearing so many times and only the last record selected appears in the patient_list.

Thank you for your suggestions and your help.

----------------------------------------------------------------------
Re: dynamic selection of records based on checkbox checked [message #78033 is a reply to message #78028] Fri, 04 January 2002 19:38 Go to previous messageGo to next message
rama krishna
Messages: 97
Registered: December 2001
Member
there is a problem in ur loop, the problem is u r not navigating between records in the block, thats why its taking only one value repeatedly. so give next_record in loop.

----------------------------------------------------------------------
Re: dynamic selection of records based on checkbox checked [message #78038 is a reply to message #78028] Sun, 06 January 2002 04:05 Go to previous messageGo to next message
Shilpa
Messages: 59
Registered: November 2001
Member
Increment the value of I just before the end loop.
Re: dynamic selection of records based on checkbox checked [message #78046 is a reply to message #78028] Mon, 07 January 2002 07:19 Go to previous message
Ramaa
Messages: 7
Registered: December 2001
Junior Member
Thank you for pointing out the mistake.

I added go_record(first_record) before the loop
statement and next_record before the end loop statement and the code started working in the way I wanted.

Thanks.
Rama.
Previous Topic: Columns
Next Topic: *** Report security**
Goto Forum:
  


Current Time: Fri Apr 19 11:46:19 CDT 2024