2
votes

When user begin filling the record then they click other record before committing i want to clear the last record like it never filled.

So i create when-validate-record in data block as below:

begin
  if :MYBLOCK.SEQ is null then --if there is no seq yet, means its not committed
    Clear_Record;
  end if;
end;

But clear_record causes error that says Invalid limited CLEAR_RECORD procedure and usage seems correct to me. And i also tried Clear_Record(no_validate) but it also doesn't work. I saw some usage of clear_record and i can't get why it doesn't work. I could use some help.

Thanks in advance.

1

1 Answers

2
votes

Restricted procedures (not limited, as you put it) can't be called from all triggers; WHEN-VALIDATE-RECORD being one of them.

One option you might choose is to interact with the user and tell them what to do. Still the WHEN-VALIDATE-RECORD trigger:

if :MYBLOCK.SEQ is null then -- if there is no seq yet, means its not committed
   message('Save the record or - if you do not need it - delete it');
   raise form_trigger_failure;
end if;

Benefit of such an approach is that user (not the procedure in background) decides what to do. I wouldn't want to enter 20 fields on the screen, accidentally click one of previous records and lose everything I've done so far.