Count # of records of block based on flag insert mode [message #185850] |
Thu, 03 August 2006 17:38 |
reddy2006
Messages: 2 Registered: August 2006
|
Junior Member |
|
|
This form is Driving me crazy. Can anyone give me an idea on how to do this. I have 3 columns Interface_name, effective_date, required_flag in a block. For example if the data is as follows. before saving (inserting into database) I have to count the number of records for each distinct combination of interface_name and required_flag.
I am writing this on Key-Commit trigger.
Interface_name effective_date required_flag
Interface1 ----- jun 20 ------ Y
Interface2 ----- jun 21 ------ N
Interface1 ----- june 15 ------ Y
Interface1 ----- jun 14 ------ Y
Interface2 ----- jun 1 ------ N
Interface3 ----- may 4 ------ Y
For the above example I want count_interface_yes = 2 and count_interface_no = 1
I am trying to two loops using go_record but not able to figure out how to acheive this. Can anyone help me write the logic?
|
|
|
Re: Count # of records of block based on flag insert mode [message #185992 is a reply to message #185850] |
Fri, 04 August 2006 12:57 |
jowahl
Messages: 82 Registered: May 2006
|
Member |
|
|
it would be easier if you_re commiting and AFTER that you're counting the distinct values from the database and display the results on the form.
if this is not possible and you don't know how many different values of interface_name may exist, i'd recommend to loop through the records and store (add) the values in a pl/sql table.
after that read the counts and display them.
i can give you some examples if you like ....
|
|
|
|
Re: Count # of records of block based on flag insert mode [message #186228 is a reply to message #186019] |
Mon, 07 August 2006 02:31 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
I am assuming that have two and only two Interface Names.
In your control (non-database) block create a couple of number items and a couple of varchar2 item big enough to hold an Interface Name, they don't have to be displayed.
In your When-New-Form-Instance set them to '0' (zero) and blank.
Then in the When-Checkbox-Changed test to see if the Interface_name_1 has been set, if yes then based on whether the checkbox istrue or false (remember they can be turned off) increment or decrement the counter for Interface_name_1. If the Interface_name_1 is set, does it match this Interface name? If yes, test checkbox and increment or decrement. If set and defferent then do the counting in the second storage pair.
If you have MANY interface name then you need to use an array.
David
|
|
|