Home » Developer & Programmer » Forms » Numbering in multi data block Oracle Forms 11g (Oracle Forms 11g)
Numbering in multi data block Oracle Forms 11g [message #656032] Wed, 21 September 2016 03:22 Go to next message
avni
Messages: 4
Registered: September 2016
Junior Member
I have a multi data block (6 records) and check box in the same block .
I want to number the records when check box is checked , and when the check box is unchecked , the numbering should rearrange itself in checking order ,
and next checked value should also come in the checking order.
(numbers are displayed in another TextItem in same block )


for example.
values when checked (I am checking all the 6 records in an order) then the TextItem values become
1
2
3
4
5
6
and when I uncheck 3 then it should rearrange as
1
2

3
4
5
and when '1' is unchecked then,

1

2
3
4
And again I am checking the 3rd record then

1
5
2
3
4
And again I am checking the 1st record then
6
1
5
2
3
4
Please help me to do this .I have tried using sequence , but in vain .
Re: Numbering in multi data block Oracle Forms 11g [message #656071 is a reply to message #656032] Wed, 21 September 2016 14:48 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What is the purpose of that task? I can't imagine any ...

It appears that there are two algorithms: one when you uncheck the checkbox (so you rearrange numbers so that they are always in ascending order - that's rather simple - loop through all rows, increment a counter variable by 1 and put its value into a text item). Another one is when you check unckecked checkboxes (so you put the highest value into that row's text item - so, remember where you currently are (:SYSTEM.TRIGGER_RECORD), loop again, count all checked checkboxes, increment that number by 1, return to starting point (GO_RECORD) and store a value).

Re: Numbering in multi data block Oracle Forms 11g [message #656089 is a reply to message #656071] Thu, 22 September 2016 05:26 Go to previous messageGo to next message
avni
Messages: 4
Registered: September 2016
Junior Member
Dear LittleFoot,
Thanks for your reply .
I have achieved it Smile , thank you again

The real scenario here is , the selection of inventory in clicking order should be available to the next level
supervisor in the same order , so that he can process the inventories based on that order.
And also the first level supervisor need not check the whole record in his screen and can check records in any
order .

I am posting here the query what I wrote in checkbox changed .
DECLARE
	P_VAL NUMBER;
	
	P_UVAL NUMBER;
		
	p_max number;
	CNT NUMBER:=0;
	CH_CN NUMBER:=0;
	

BEGIN
	if :BLK.CHKBX=1 then
		
							if 	:CHK_CNT= 0 then
							begin
							--HERE SELECT THE MAX COUNT FROM THE DATABASE TABLE FOR THAT DAY AND STORE IN P_MAX --
											
											
											
																	if p_max is  null then
																	:CHK_CNT:=:CHK_CNT+1;
																	
																	:BLK.fm_seq :=	:CHK_CNT;
																	
																	end if;
																	if p_max is not null then
																	:CHK_CNT:= p_max+1;
																	:BLK.fm_seq :=:CHK_CNT ;
																	
																	end if;
											exception when no_data_found then
											null;
											
							
										
							
							end;
						
	elsif :CHK_CNT >0 then
		:CHK_CNT:=:CHK_CNT+1;
					        	   	   
						:BLK.fm_seq :=	:CHK_CNT;
	end if;
	
	end if;	
	
	if :BLK.CHKBX=0 then
	:CHK_CNT:=:CHK_CNT-1;
	end if;
	
	

IF :BLK.CHKBX=0 THEN
	 
	 	P_UVAL:=:BLK.fm_seq ;

		:BLK.fm_seq := NULL;
		
		go_block('BLK');
FIRST_RECORD;

	WHILE :SYSTEM.LAST_RECORD='FALSE' 
	LOOP
		
			IF :BLK.CHKBX=1 THEN
								P_VAL:=:BLK.fm_seq;
								
								
								IF P_VAL>P_UVAL THEN  -- CURRNT RECORD VAL >UNCHKD VALUE
													  :BLK.fm_seq :=P_VAL-	1 ;
										  	
										
									END IF;
		
			END IF;
	NEXT_RECORD;
			
	END LOOP;
	
	FIRST_RECORD;
	
END IF;
			
END ;
Regards,


[EDITED by LF: applied [code] tags]

[Updated on: Thu, 22 September 2016 12:54] by Moderator

Report message to a moderator

Re: Numbering in multi data block Oracle Forms 11g [message #656090 is a reply to message #656089] Thu, 22 September 2016 06:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" or "Preview Quick Reply" button to verify.

Re: Numbering in multi data block Oracle Forms 11g [message #656111 is a reply to message #656090] Thu, 22 September 2016 12:58 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Thank you for posting the code you wrote.

I applied [code] tags so that you could see that - even though it might look OK in Forms, it looks horrible when posted on the Forum. I'd suggest you to use code formatter, such as Instant SQL Formatter; bookmark it.

Properly formatted and easy to read, your code looks like this:
 DECLARE
    p_val  NUMBER;
    p_uval NUMBER;
    p_max  NUMBER;
    cnt    NUMBER := 0;
    ch_cn  NUMBER := 0;
BEGIN
    IF :BLK.chkbx = 1 THEN
      IF :CHK_CNT = 0 THEN
        BEGIN
            --HERE SELECT THE MAX COUNT FROM THE DATABASE TABLE FOR THAT DAY AND STORE IN P_MAX --
            IF p_max IS NULL THEN
              :CHK_CNT := :CHK_CNT + 1;

              :BLK.fm_seq := :CHK_CNT;
            END IF;

            IF p_max IS NOT NULL THEN
              :CHK_CNT := p_max + 1;

              :BLK.fm_seq := :CHK_CNT;
            END IF;
        EXCEPTION
            WHEN no_data_found THEN
              NULL;
        END;
      ELSIF :CHK_CNT > 0 THEN
        :CHK_CNT := :CHK_CNT + 1;

        :BLK.fm_seq := :CHK_CNT;
      END IF;
    END IF;

    IF :BLK.chkbx = 0 THEN
      :CHK_CNT := :CHK_CNT - 1;
    END IF;

    IF :BLK.chkbx = 0 THEN
      p_uval := :BLK.fm_seq;

      :BLK.fm_seq := NULL;

      Go_block('BLK');

      first_record;

      WHILE :SYSTEM.last_record = 'FALSE' LOOP
          IF :BLK.chkbx = 1 THEN
            p_val := :BLK.fm_seq;

            IF p_val > p_uval THEN -- CURRNT RECORD VAL >UNCHKD VALUE
              :BLK.fm_seq := p_val - 1;
            END IF;
          END IF;

          next_record;
      END LOOP;

      first_record;
    END IF;
END;  
See the difference?

I didn't look closely at your code; however, I'm pretty much sure that you don't need the EXCEPTION handler because nothing - in the code you posted - can raise the NO-DATA-FOUND (there's no SELECT statement here).
Re: Numbering in multi data block Oracle Forms 11g [message #656113 is a reply to message #656111] Thu, 22 September 2016 13:15 Go to previous messageGo to next message
avni
Messages: 4
Registered: September 2016
Junior Member
Thank you for the suggestion. Will follow in the future .
Exception handler is required here as there is a SELECT statement which i have'nt written but noted as
--HERE SELECT THE MAX COUNT FROM THE DATABASE TABLE FOR THAT DAY AND STORE IN P_MAX --

inside the code.

Have a great day.
Re: Numbering in multi data block Oracle Forms 11g [message #656118 is a reply to message #656113] Fri, 23 September 2016 04:43 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
The exception handler looks to be in the wrong place. I assume you want the IFs after the select to run even if it finds no data, in which case the exception section needs to be immediately after select.
Also some ELSE's would simplify the code a bit.
Previous Topic: MMB file smaller when saved
Next Topic: ORA-24813: cannot send or receive an unsupported LOB.
Goto Forum:
  


Current Time: Tue Apr 23 07:05:08 CDT 2024