Home » Developer & Programmer » Forms » How to skip values in a cursor, not to populate in Data Block ? (Oracle Form (10.1.2.0.2), Windows)
How to skip values in a cursor, not to populate in Data Block ? [message #642579] Tue, 15 September 2015 01:11 Go to next message
malya
Messages: 22
Registered: August 2015
Location: Hyderabad, India
Junior Member
I am populating a cursor values into a data block. I Want to skip 2 rows of values from a cursor for a specific condition. I tried with Continue statement but it does not support it seems.

Problem :
----------
When Activity like 'TCP' for a unit in a specific hour, I want to skip it to pupulate it in data block and continue with the next values in cursor to populate in the data block.

Please help. Code snippet is given below.

GO_BLOCK('PRODRPT');
CLEAR_BLOCK(NO_VALIDATE);
FIRST_RECORD;
FOR CUR IN MAST LOOP
	:UNITNAME := l_unit;
	:PROJNAME := NVL(CUR.ACTIVITY,'');
	:PRODCODE := NVL(CUR.TYPE,'');
	:PRODRPT.shiftcode := l_shiftcode;
	:hour := l_hour;
	:figure := 0;	
	:SMS := l_smsflag;

-- Not supporting below stmt. Giving error as identifier continue must be declared.
/*	
         IF l_unit = <<unitcode>> AND l_hour <> '<<hour>>' AND NVL(CUR.ACTIVITY,'') IN       
          ('TCP','CLO') THEN
        	CONTINUE;
	 END IF;	
*/	
        NEXT_RECORD;
	END LOOP;
Re: How to skip values in a cursor, not to populate in Data Block ? [message #642580 is a reply to message #642579] Tue, 15 September 2015 01:46 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Not "continue"; try "null;" instead:
IF l_unit = <<unitcode>> AND l_hour <> '<<hour>>' AND NVL(CUR.ACTIVITY,'') IN ('TCP','CLO') THEN
   null;
END IF;	
Re: How to skip values in a cursor, not to populate in Data Block ? [message #642582 is a reply to message #642580] Tue, 15 September 2015 02:34 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you want those rows to not go in the datablock then the obvious thing to do is to change the cursor to not select them in the first place.
Otherwise you need to wrap the code that assigns values to the datablock items in an IF.

Also '' is the same as null. So this:
NVL(CUR.ACTIVITY,'')

Is the same as:
CUR.ACTIVITY
Re: How to skip values in a cursor, not to populate in Data Block ? [message #642608 is a reply to message #642582] Tue, 15 September 2015 08:22 Go to previous messageGo to next message
CraigB
Messages: 386
Registered: August 2014
Location: Utah, USA
Senior Member
Quote:
When Activity like 'TCP' for a unit in a specific hour, I want to skip it to pupulate it in data block and continue with the next values in cursor to populate in the data block.

Your LOOP logic is wrong. If you want to skip these values then you need your assignments to be within your conditional statement. The way you have your code written, you will always assign values even when your conditional is TRUE. Try...
GO_BLOCK('PRODRPT');
CLEAR_BLOCK(NO_VALIDATE);
FIRST_RECORD;
FOR CUR IN MAST LOOP
    IF l_unit = <<unitcode>> AND l_hour <> '<<hour>>' AND NVL(CUR.ACTIVITY,'') IN ('TCP','CLO') THEN
       null;
    ELSE
       :UNITNAME := l_unit;
       :PROJNAME := NVL(CUR.ACTIVITY,'');
       :PRODCODE := NVL(CUR.TYPE,'');
       :PRODRPT.shiftcode := l_shiftcode;
       :hour := l_hour;
       :figure := 0;	
       :SMS := l_smsflag;
    END IF;	
    NEXT_RECORD;
END LOOP;

Craig...
Re: How to skip values in a cursor, not to populate in Data Block ? [message #642609 is a reply to message #642608] Tue, 15 September 2015 08:25 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
The next_record needs to be inside the IF statement after the item assignments, otherwise there will be blank records in the block - or next_record will throw an error.
icon14.gif  Re: How to skip values in a cursor, not to populate in Data Block ? [message #642630 is a reply to message #642608] Tue, 15 September 2015 11:00 Go to previous message
malya
Messages: 22
Registered: August 2015
Location: Hyderabad, India
Junior Member
Thank You Littlefoot, Cookiemonster, Craig. It worked for me. Smile
Previous Topic: Upgrading old oracle forms
Next Topic: when-validate-item trigger fires multiple times
Goto Forum:
  


Current Time: Fri Apr 19 18:31:27 CDT 2024