Problem: You have required items in a block but the user needs to navigate to another block before all items are filled in.
Solution: The following code sets the required items to a state of "valid" before leaving the block and resets the block to "to be validated" (by copying a NULL value into an item that has no value) upon reentering the block.
procedure p_setvalid(p_onoff varchar2) is
/*****************************************************************
* A standard procedure allowing users to leave a block with
*
* required items not yet entered, and to re-set them on
*
* return to the block
*
* Usage - before leaving the block
*
* p_setvalid('on');
*
* and on return to the block
*
* p_setvalid('off');
*
*
*
* Change history
*
* ==============
*
*
*
* Vsn Date By
Details
*
* ====== ====== ======= =====================================
*
* 1.0 Jun 98 Mal Original
version
*
* 1.1 Aug 00 Mal Add
validation on current item
*
*
*
*****************************************************************/
v_block
varchar2(10);
v_field
varchar2(30);
v_field_type varchar2(30);
v_nextfield
varchar2(30);
v_blockfield varchar2(30);
v_retval
varchar2(10);
v_required
varchar2(5);
v_onoff
varchar2(3);
begin
if upper(p_onoff) = 'ON' then
v_onoff := 'ON';
else
v_onoff := 'OFF';
end if;
/* Check that current field is valid if it's not null
*/
if v_onoff = 'ON'
and name_in('system.cursor_value')
is not null then
p_check_field;
end if;
v_block := name_in('system.cursor_block');
v_field := get_block_property(v_block,first_item);
loop
v_blockfield := v_block || '.' || v_field;
v_field_type := get_item_property(v_blockfield,item_type);
if v_field_type = 'TEXT ITEM' then
v_retval
:= get_item_property(v_blockfield,enabled);
if v_retval = 'TRUE' then
v_required :=
get_item_property(v_blockfield,required);
if v_required
= 'TRUE' then
if v_onoff = 'ON' then
set_item_property(v_blockfield,item_is_valid);
else
if name_in(v_blockfield) is null then
copy (null,v_blockfield);
end if;
end if;
end if;
end if;
end if;
v_nextfield := get_item_property(v_blockfield,nextitem);
if v_nextfield is null
then exit;
end if;
v_field := v_nextfield;
end loop;
end;
===============================================================
procedure p_check_field
is
begin
enter;
if not form_success then
raise form_trigger_failure;
end if;
end;
Malcolm Turner (1 Apr, 2001)
Exit to : Oracle
Hints and Tips