Solved

Highlighting a Record based on criteria

Posted on 2004-08-17
6
1,982 Views
Last Modified: 2008-01-09
Right now I have some criteria that will change the background color of an Item within a record.  But right now it will change the color of all the items, no matter what record it is.

Here is what I need to do - I have 3 records displayed (with a scrollbar if more items exist) in a column style.  Meaning that record 1 is column 1, and record 2 is column 2, etc.  Right now I find if A>B then change the background color of Field1.  This will change the color of Field1 in all the records:

SET_ITEM_PROPERTY('Field1', VISUAL_ATTRIBUTE, 'BACKGROUND_YELLOW');

I would like to change the color of all the items in Record1, but not in Record2.  Can this be done?  and if so can someone get me started on the right track?
0
Comment
Question by:Intern
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:andrewst
ID: 11825015
The built-in you need is SET_ITEM_INSTANCE_PROPERTY.  That only changes the properties on specified row.
0
 
LVL 5

Expert Comment

by:FBIAGENT
ID: 11825032
You should be able to use built-in function

 SET_ITEM_INSTANCE_PROPERTY('<block_name>.Field1', <record_number>, VISUAL_ATTRIBUTE, 'BACKGROUND_YELLOW');

<record_number> is the record number within the block
0
 
LVL 1

Author Comment

by:Intern
ID: 11825400
FBIAGENT - Thanks that helped some.

I have a couple more questions that I need to answer to get this to work correctly.

First - I need to loop through the items in that particular record and change the background for all of them.  What is the best way to do this?  I could hard-code each item, but that is not exactly "good" programming style.

Secondly - What property or value can I use to find out the current record? (i.e. <record_number>)  I am not sure how I can programmable find this value.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:FBIAGENT
ID: 11825514
"First - I need to loop through the items in that particular record and change the background for all of them.  What is the best way to do this?  I could hard-code each item, but that is not exactly "good" programming style."

I would put the logic to change the record attribute in the block-level POST-QUERY trigger, and appropriate item-level WHEN-VALIDATE-ITEM triggers

"Secondly - What property or value can I use to find out the current record? (i.e. <record_number>)  I am not sure how I can programmable find this value."

If you put the SET_ITEM_INSTANCE_PROPERTY() in the POST-QUERY and WHEN-VALIDATE-ITEM triggers, then the <record_number> is :system.trigger_record
0
 
LVL 1

Author Comment

by:Intern
ID: 11825609
Thanks - I just need a little clarification on the First point

- If I have 3 items - BLOCK.Field1, BLOCK.Field2, BLOCK.Field3

How do I create a loop that will loop through all the fields in that block.  I know where to put the code, just not sure of the syntax on how to do it.
0
 
LVL 5

Accepted Solution

by:
FBIAGENT earned 500 total points
ID: 11826105
You could simply do

set_item_instance_property('block.field1',:sytem.trigger_record,visual_attribute,'background_yellow');
set_item_instance_property('block.field2',:sytem.trigger_record,visual_attribute,'background_yellow');
set_item_instance_property('block.field3',:sytem.trigger_record,visual_attribute,'background_yellow');

or loop through all items in the block as follows

declare
   blk_name                           varchar2(30) := 'BLOCK';
   block_handle                       block;
   block_current_item                 varchar2(30);
   block_last_item                    varchar2(30);
   error_msg                          varchar2(255);
   item_handle                        item;
begin
   -- set up for loop to traverse all the items in the block

   block_handle := find_block(blk_name);
   block_current_item := get_block_property(block_handle, first_item);
   block_last_item := get_block_property(block_handle, last_item);

   -- loop to traverse every item in the block
   loop
      -- verify that the item exists
      item_handle := find_item(blk_name || '.' || block_current_item);

      -- set attribute of the item if condition satisfies
      if ... then
         set_item_instance_property(item_handle,:system.trigger_record,visual_attribute,'BACKGROUND_YELLOW');
      end if;

      -- at end of loop either go to the next item or end looping if at the
      -- last item in this block
      exit when block_current_item = block_last_item;
      block_current_item := get_item_property(item_handle, nextitem);
   end loop;
end;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ODBC in excel 2016 in Windows 10 via VBA 16 250
Deleting Rows from an Oracle Database - Performance 19 74
Read XML values 8 56
UTL_FILE invalid file operation 5 45
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many‚Ķ
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question