Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use first_record or Next_record in WHEN-VALIDATE-ITEM.

373320Sep 12 2008 — edited Sep 15 2008
Hi All,

I have a multi-record block where, in one of the fields I need to add this PL/SQL so that for there is no gaps in sequence for S_type and cer_dl fields.below is the sample of how the record should appear.

s_type cer_dl seq xyz
ASD Y 1 N
ASD Y 2 Y
ASD Y 3 N

The program is working perfectly when I use it Key-Next-item but I have to add this pl/sql in WHEN-VALIDATE-ITEM for validating the seq field but as the below program have FIRST_RECORD and NEXT_RECORD this will fail in WHEN-VALIDATE-ITEM.
My Query is that IS there any other way of replacing FIRST_RECORD and NEXT_RECORD
in the below program and put this in WHEN-VALIDATE-iTEM of seq field.

I know its pain to understand the below pl/sql and then answer my query.
----------------------------------------------------------------------------------
PROCEDURE val_seq IS
--Validation to check that there is no gaps in sequence for S_TYPE and cer_dl fields
l_value_to_check varchar2(100);
l_seq_found number;
l_curr_sequence number;
l_new_value varchar2(100);
l_found boolean:=FALSE;
l_new_set boolean := FALSE; --s_type and cer_dl are different from previous set.
begin
if trim(:b1.s_type) is not null
or trim(:b1.cer_dl) is not null
then
-- Program continues here only if all the items are not null
-- Get information from record that needs to be validated
l_value_to_check := trim(:b1.s_type) || ':'|| trim(:b1.cer_dl) ;
l_curr_sequence := :sequence;

if :SYSTEM.CURSOR_RECORD = '1' then
if :sequence <> 1 then ----- to check sequence is entered as 1 in the first record
message('Error:Sequence should start with 1');
raise form_trigger_failure;
end if;
go_item('b1.XYZ');
else
FIRST_RECORD;
while :SYSTEM.LAST_RECORD <> 'TRUE'
loop
l_found := FALSE;
l_new_value := trim(:b1.S_type) || ':'|| trim(:cer_dl) ;

if l_new_value = l_value_to_check then -- If the S_type and cer_dl is same then get sequence
l_new_set:= FALSE;
l_seq_found := :seq;

if l_seq_found >= l_curr_sequence then
--If sequence is duplicated for S_type and cer_dl
go_item('b1.seq');
l_new_set := FALSE;
elsif l_seq_found < l_curr_sequence - 1 then
--If sequence entered is not in order for S_type and cer_dl .
go_item('b1.sequence');
l_found := FALSE;
elsif l_seq_found = l_curr_sequence - 1 then
-- if sequence is entered in order for S_type and cer_dl
l_found:= TRUE;
go_item('b1.xyz); --go to next item
end if;
else
l_new_set := TRUE;
end if;
NEXT_RECORD;
end loop;
if l_new_set then
go_item('b1.xyz'); -- go to next item
else
if not l_found then
warn_alert('Error:Sequence should be in order.');
go_item('b1.seq');
raise form_trigger_failure;
end if;
end if;
go_item('b1.xyz'); ---go to next item
end if;
end if;
end;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 13 2008
Added on Sep 12 2008
15 comments
8,325 views