Home » Developer & Programmer » Forms » Oracle forms Check box Manipulation (oracle forms 10g)
Oracle forms Check box Manipulation [message #626962] Wed, 05 November 2014 13:56 Go to next message
Asfakul
Messages: 43
Registered: July 2014
Member
HI all,

I have a form in which there is a check box(select all) which if selected selects all the records.
I am trying to implement the feature where if I unselect any of the record, select all check box would get un checked. here is my code so far

declare
	L_ind char(1):='Y';
	L_rec_count NUMBER:=0;
begin
	go_block('b_search_result');
	last_record;
	L_rec_count:=:system.last_record;
	first_record;
	if :b_action.cb_select_all='Y' then
		for c in 1..L_rec_count
	    loop
	    	go_record(c);
		    if :b_search_result.cb_select_single='N' then
			  L_ind:='N';
		   end if;
	   end loop;
	end if;
		if 	L_ind='N' then
			 :b_action.cb_select_all:='N';
		end if;
		
		exception
			when others then
			  message(sqlerrm);
			  raise form_trigger_failure;
end;



which is throwing the error NO DATA FOUND. I dont know how this error is being generated. Please help. Also let me know how can I check the value of an intermediate variable in a form?

.fmb file is attached for your reference.

[Updated on: Wed, 05 November 2014 13:57]

Report message to a moderator

Re: Oracle forms Check box Manipulation [message #626963 is a reply to message #626962] Wed, 05 November 2014 15:11 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
I didn't look at your code too close as it would be hard to follow without the form and I am not downloading the form.
you do not mention anything about if any of the fields are database or non-database fields, whether the "all" field is in the same block or another, etc.
For me, if any of the checkboxes are unchecked, all you do is somthing like:
:block.the_all_field := NULL;

QED
Re: Oracle forms Check box Manipulation [message #626964 is a reply to message #626963] Wed, 05 November 2014 15:36 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Besides, your code is wrong - it'll never work. :SYSTEM.LAST_RECORD is either TRUE or FALSE, it doesn't contain record number.

Moreover, it can NOT raise NO-DATA-FOUND; it is raised by some other code. Which one? Run form in debug mode and you'll know.

Quote:

I am trying to implement the feature where if I unselect any of the record, select all check box would get un checked

You could try with WHEN-VALIDATE-ITEM trigger on the record's checkbox item, which would look like
if :b_search_result.cb_select_single = 'N' then
   :b_action.cb_select_all := 'N';
end if;
Re: Oracle forms Check box Manipulation [message #626987 is a reply to message #626964] Thu, 06 November 2014 03:10 Go to previous messageGo to next message
cookiemonster
Messages: 13919
Registered: September 2008
Location: Rainy Manchester
Senior Member
As LF points out your code is wrong, so as it stands it'll raise an ORA-6502 error, unless the go_block or last_record fires a trigger that causes another error.
Re: Oracle forms Check box Manipulation [message #626990 is a reply to message #626987] Thu, 06 November 2014 04:49 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
Yes! your code seems wrong any how I tried to run your uploaded .fmb file but i am unable to open which form version r you using. What logic are your trying to implement while DESELECTING single checkbox and MY 2nd question is that in your form "SELECT_ALL" & "DESELECT_ALL" are properly working or not.


Regards
Mughal
Re: Oracle forms Check box Manipulation [message #626991 is a reply to message #626990] Thu, 06 November 2014 05:05 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
This is example .fmb file download this compile and run & Lets go step by step please let me know what else you want in this .fmb


Regards
Mughal

[Updated on: Thu, 06 November 2014 05:07]

Report message to a moderator

Re: Oracle forms Check box Manipulation [message #627027 is a reply to message #626964] Thu, 06 November 2014 11:38 Go to previous messageGo to next message
Asfakul
Messages: 43
Registered: July 2014
Member
Yeah sorry it's wrong. It should have been :system.cursor_record;

Re: Oracle forms Check box Manipulation [message #627058 is a reply to message #626990] Thu, 06 November 2014 21:45 Go to previous messageGo to next message
Asfakul
Messages: 43
Registered: July 2014
Member
Thanks for looking into. I have successfully fixed it now. Please see the below code -

declare
	L_ind char(1):='Y';
	L_rec_count NUMBER:=0;
begin
	go_block('b_search_result');
	last_record;
	L_rec_count:=:system.cursor_record;
	first_record;
	if :b_action.cb_select_all='Y' then
		for c in 1..L_rec_count
	    loop
	    	go_record(c);
		    if :b_search_result.cb_select_single='N' then
			  L_ind:='N';
		   end if;
	    end loop;
	else
	   	for c in 1..L_rec_count
	    loop
	    	go_record(c);
		    if :b_search_result.cb_select_single='N' then
			  L_ind:='N';
		   end if;
	    end loop;
	       	
	end if;
		if 	L_ind='N' then
			 :b_action.cb_select_all:='N';
		else
			 :b_action.cb_select_all:='Y';
		end if;
		
		exception
			when others then
			  message(sqlerrm);
			  raise form_trigger_failure;
end;



Re: Oracle forms Check box Manipulation [message #627092 is a reply to message #627058] Fri, 07 November 2014 03:18 Go to previous messageGo to next message
cookiemonster
Messages: 13919
Registered: September 2008
Location: Rainy Manchester
Senior Member
The first IF statement is pointless since you do the same code in both sections of IF.
The simplest way to loop over records is:
first_record;
LOOP
  <do_stuff>
  EXIT WHEN :system.last_record = 'TRUE';
  next_record;
END LOOP;


You don't have anything to put the cursor back in the record it was in at the start, it'll always end up in the last record regardless of which record the user had last selected.

And as LF pointed out above you don't need to do any looping at all. You could just set the select all checkbox when one of the detail checkboxes is changed.
Re: Oracle forms Check box Manipulation [message #627354 is a reply to message #626990] Tue, 11 November 2014 04:24 Go to previous messageGo to next message
atlorcl
Messages: 1
Registered: November 2014
Location: Bermuda
Junior Member
hi mughal sir , i will be grateful to you if you could add delete mutiple record using checkbox in same fmb.
Re: Oracle forms Check box Manipulation [message #627355 is a reply to message #627354] Tue, 11 November 2014 04:29 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
Sure brother

Begin
go_block('CHKBOX');
    first_record;
 LOOP
    EXIT WHEN :SYSTEM.RECORD_STATUS='NEW';
 if :CHKBOX.CHK = 'Y' then 
     DELETE_RECORD;
   else
    EXIT WHEN :SYSTEM.LAST_RECORD='TRUE';
NEXT_RECORD;
   end if;
END LOOP;
--COMMIT;
end;


Regard
Mughal

[Updated on: Tue, 11 November 2014 04:32]

Report message to a moderator

Re: Oracle forms Check box Manipulation [message #627743 is a reply to message #627355] Sat, 15 November 2014 10:21 Go to previous message
Asfakul
Messages: 43
Registered: July 2014
Member
Thanks Mughal .. Thanks for the useful coding example
Previous Topic: Forrm Builder Font
Next Topic: Unable to delete a record from a block based on a View
Goto Forum:
  


Current Time: Tue Apr 16 05:13:35 CDT 2024