Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Looping thru items in a block

585 views
Skip to first unread message

BigM

unread,
Jul 19, 2002, 10:28:32 AM7/19/02
to
Hi,

I am wanting to process all items within a block and set the visual
attribute according to a value retrieved from the database. This to be
done on when-new-block-instance.

Code is as below but using next_item triggers of validation etc.....is
there any other way of looping through items in a block?

WHILE vCurrItem != vLastItem
LOOP
SET_ITEM_PROPERTY (:SYSTEM.current_item, VISUAL_ATTRIBUTE, 'RED');
NEXT_ITEM;
END LOOP;

TIA

BigM

Scott Mattes

unread,
Jul 19, 2002, 10:34:39 AM7/19/02
to
This might be overkill, I use it to dump debug info during on-error at the
form level, but you are welcome to it.

========
PROCEDURE walk_blocks_get_item_info( error_file text_io.file_type )
IS
/*

** Built-in: GET_ITEM_PROPERTY
** Example: Navigate to the next required item in the
** current block. */

cur_itm VARCHAR2(80);
orig_itm VARCHAR2(80);
first_itm VARCHAR2(80);
last_itm varchar2(80);

a_item_type varchar2(80);

cur_blk varchar2( 80 );

/*
** Local function returning the name of the item after the
** one passed in. Using NVL we make the item after the
** last one in the block equal the first item again.
*/
FUNCTION The_Item_After(itm VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN cur_blk||'.'||
NVL(Get_Item_Property(itm,NEXTITEM),
first_itm);
END;

procedure get_item_props
is
begin
text_io.put( error_file, ' item_name=' || get_item_property( cur_itm,
item_name ) );

a_item_type := get_item_property( cur_itm, item_type );
if a_item_type in ( 'DISPLAY ITEM', 'TEXT ITEM' )
then
begin
text_io.put( error_file, ', column_name=' || get_item_property(
cur_itm, column_name ) );
text_io.put( error_file, ', database_value="' || get_item_property(
cur_itm, database_value ) || '"' );
text_io.put( error_file, ', datatype=' || get_item_property( cur_itm,
datatype ) );
exception
when others
then
text_io.put( error_file, ', not a database item, ' );
end;
end if;

text_io.put( error_file, ', displayed=' || get_item_property( cur_itm,
displayed ) );

if a_item_type not in ( 'DISPLAY ITEM' )
then
text_io.put( error_file, ', enabled=' || get_item_property( cur_itm,
enabled ) );
end if;

text_io.put( error_file, ', item_canvas=' || get_item_property( cur_itm,
item_canvas ) );
text_io.put( error_file, ', item_type=' || get_item_property( cur_itm,
item_type ) );
text_io.put( error_file, ', item_tab_page=' || get_item_property(
cur_itm, item_tab_page ) );

if a_item_type in ( 'TEXT ITEM' )
then
text_io.put( error_file, ', item_is_valid=' || get_item_property(
cur_itm, item_is_valid ) );
text_io.put( error_file, ', list=' || get_item_property( cur_itm,
list ) );

if get_item_property( cur_itm, list ) is not null
then
text_io.put( error_file, ', lov_name=' || get_item_property(
cur_itm, lov_name ) );
text_io.put( error_file, ' lov record group name=' ||
get_lov_property( lov_name, group_name ) );
end if;
end if;

if a_item_type in ( 'DISPLAY ITEM', 'TEXT ITEM' )
then
text_io.put( error_file, ', max_length=' || get_item_property( cur_itm,
max_length ) );
end if;

if a_item_type not in ( 'DISPLAY ITEM' )
then
text_io.put( error_file, ', navigable=' || get_item_property( cur_itm,
navigable ) );
end if;

if a_item_type in ( 'TEXT ITEM' )
then
text_io.put( error_file, ', required=' || get_item_property( cur_itm,
required ) );
text_io.put( error_file, ', validate_from_list=' ||
get_item_property( cur_itm, validate_from_list ) );
end if;

text_io.put( error_file, ', visible=' || get_item_property( cur_itm,
visible ) );
text_io.put_line( error_file, ', visual_attribute=' ||
get_item_property( cur_itm, visual_attribute ) );

end;


BEGIN

cur_blk := get_form_property( :system.current_form, first_block );

while ( cur_blk is not null )
loop
text_io.put_line( error_file, '======' );
text_io.put_line( error_file, 'block=' || cur_blk );

text_io.put_line( error_file, ' current record=' ||
get_block_property( cur_blk, current_record ) );
text_io.put_line( error_file, ' default where=' ||
get_block_property( cur_blk, default_where ) );
text_io.put_line( error_file, ' delete allowed=' ||
get_block_property( cur_blk, delete_allowed ) );
text_io.put_line( error_file, ' enforce primary key=' ||
get_block_property( cur_blk, enforce_primary_key ) );
text_io.put_line( error_file, ' enterable=' || get_block_property(
cur_blk, enterable ) );
text_io.put_line( error_file, ' insert allowed=' ||
get_block_property( cur_blk, insert_allowed ) );
text_io.put_line( error_file, ' last query=' || get_block_property(
cur_blk, last_query ) );
text_io.put_line( error_file, ' order by=' || get_block_property(
cur_blk, order_by ) );
text_io.put_line( error_file, ' query allowed=' ||
get_block_property( cur_blk, query_allowed ) );
text_io.put_line( error_file, ' query data source name=' ||
get_block_property( cur_blk, query_data_source_name ) );
text_io.put_line( error_file, ' query data source type=' ||
get_block_property( cur_blk, query_data_source_type ) );
text_io.put_line( error_file, ' query hits=' || get_block_property(
cur_blk, query_hits ) );
text_io.put_line( error_file, ' records displayed=' ||
get_block_property( cur_blk, records_displayed ) );
text_io.put_line( error_file, ' status=' || get_block_property(
cur_blk, status ) );
text_io.put_line( error_file, ' update allowed=' ||
get_block_property( cur_blk, update_allowed ) );

text_io.put_line( error_file, ' ' );

last_itm := cur_blk || '.' || Get_Block_Property( cur_blk, LAST_ITEM );
cur_itm := cur_blk || '.' || Get_Block_Property( cur_blk, FIRST_ITEM );

/*
** Loop until we come back to the item name where we started
*/
WHILE ( cur_itm <> last_itm )
LOOP

get_item_props;

/*
** Setup for next iteration
*/
cur_itm := cur_blk||'.'|| Get_Item_Property(cur_itm, NEXTITEM);

END LOOP;

get_item_props;

cur_blk := get_block_property( cur_blk, nextblock );
end loop;
END;
========


"BigM" <m.pr...@abm-uk.com> wrote in message
news:1eae8d2a.02071...@posting.google.com...

0 new messages