Oracle ADF: refresh related rows after transaction - oracle

I have an Oracle ADF entity in which there are relationships between the rows which are enforced in the database.
I'll give you a simplified case:
Suppose the attributes of MyEntityImpl are Customer, Month, and Quantity, and Quantity Rank. Suppose the primary key is (Customer, Month). Suppose the definition of "Quantity Rank" is that it must be the dense rank of the customer's quantity within the given month. So, the customer with the highest quantity in the month gets 1, then next highest gets 2, etc. (Suppose ties are broken by customer name -- it doesn't matter).
The DML for this page is set up such that, when I update any row, the "quantity rank" values of all customers in the given month are immediately recomputed and updated in the database.
So, the key question here is: what is the most natural, simplest, most "ADFish" way to make my ADF page efficiently requery and display the updated rows for the entire month whenever any value in the month changes?
For example, the user updates customer #100, month 2017-02 with a quantity of 100. That will cause some (or even all) of the other customer records in month 2017-02 to get updated "quantity rank" values. What is the best way to ensure that my ADF page refreshes those other records as well as the record that was actually updated?
Update
In the actual problem the "quantity rank" calculation is very involved and requires a lot of other database data, which is why it is done in the database. So, solutions involving Groovy expressions and what-not are probably not going to be helpful. I tried including the data required for this calculation in the entity model, so that I could have the ADF page perform the calculation, but the extra data slowed down the page noticeably. Performance is very important on this page (even more-so than usual).

If I understand your question, you want the ADF BC model updated when the data source changes. You might start by looking at active data sources Docs, here. and this blog.
If you mean the ADF Faces page issues a change to the database through the ADF Model and ADF BC layers, you can re-execute the query from the ADF FACES page, using EL to call the Execute operation on the data control, or refresh the iterator here.

Related

Variance Column in BI Publisher Report Pivot Table

I have a data model using a private data source (not from a Subject Area), so I need to do this with a BI Publisher Report (not an Analysis).
In the data model I have a column called 'Financial Plan Type' that contains a few different values such as "Forecast", "Adjusted Budget", "Original Budget", etc.
I want to create a pivot table that pivots this column and then creates a variance column between "Adjusted Budget" and "Forecast" as example. Obviously I have an 'Amount' field in the table too.
It doesn't seem that I can do this directly in the report as the formulas and flexibility seem to be limited for the Reports (although I'm not 100% sure of this as I am fairly new to OBIEE), but I was thinking that I could adjust the data model to union in a variance amount or do something else with the data model to make this work. Does anyone have any ideas and/or best practices around doing this either in the data model or in the Report itself?
This going to be abstract, but you can do this in BIP or Analysis, depends on what the data source looks like.
If you have are able to compute the variance as an extra element in the datasource (might need to model it), then BIP RTF template designer does support Pivot tables. You might still need to add some XDO code in the loops.
If you are inclined to OBIEE, you can create your OWN data source on OBIEE. You will have to use the RPD data modeller if you are on OBIEE on premise, or write the transactional SQL if you are OTBI on the cloud.
Either way, the trick is to have the variance already computed in the XML, so BIP/OBIEE can simply print it off.

sales tracker return cost from query

I am using Oracle APEX 4.1.1 to build a sales tracker. To explain things as simple as possible we have a table CALLED "CARS" of all products and their cost with the columns as "CAR" and "COST" there are about 500 cars listed and their associated costs.
We have a form setup so the sales staff can record their sales week by week. Simple form with a list of values built upon the "cars" column called "P2_CARS and I want the cost field in the form "P2_COST" to be generated from a query that runs against the table.
It will run dynamically when they change the value in P2_CARS and I have this but pretty sure its all around the wrong way or just wrong.
SELECT COST FROM CARS WHERE CARS=P2_CARS
can anyone help?

Cognos Report-need 2nd (Totals) Crosstab that is "aware" (filters) using the current Grouping

I am trying to create a report which groups on a column called "Legal Entity." When the output is directed to Excel, a separate tab will be created for each distinct entity in the query resultset.
For each Excel tab/Legal Entity, there will be two "sections." The first is a repeating section that breaks on a column "Funding Arrangement Type." After all of the Funding Arrangement Types are exhausted, there will be a single "Totals" grid which will summarize the data on the tab for the current Legal Entity. The data will be summarized across all Funding Arrangement Types within the current Legal Entity.
Because the Totals (lower) grid is really just a summarization of the same source query, Query1, I thought that I would also bind the Totals grid to it. However, if I do that, I get a run time error that tells me that I need to establish a Master-Detail relationship (If I decide to use a separate query for the Totals grid, the Totals grid "will not be aware" of the current Legal Entity/tab that must be considered when summarizing.)
Therefore, I continued with my guess at how the Master-Detail relationship should be defined. I made various attempts to link the two grids, including:
On all of the dimension (non-summarized) columns.
On Legal Entity
On Legal Entity and Funding Arrangement Type
Doing so affected previously correct totals reported in the upper cross tab results/
This Master-Detail approach is foreign and as a result I don't understand what it is doing.
I also tried to use a separate query, Query2, for the lower totals grid and adding a filter to filter SQL2 where SQL2. LegalEntity = SQL1.LegalEntity in an effort to get the totals grid to summarize within the current LeglEntity grouping. This resulted in a cross join error.
I’m a real noob with Cognos. Suggestions are welcomed. Thank you!
You can use mouse+scroll wheel to zoom in:
I was able to get it working by binding both grids to a single query and for both grids, establish a Master-Detail Replationship on Legal Entity. Prior to doing that, I added these columns to both grids and hide them, not sure if this was necessary.

Oracle Database Design View or Table?

I'm new to database design and faced a problem while trying to design one. Here's my system:
There are 3 different softwares (SW_A, SW_B, SW_C) and 500-600 users. Each user can use any of the softwares and do some work. Each work is sent to the database approx. 6 times per minute. (Randomly for users and software)
I want a database to keep all user actions related to the softwares for archive and also want to keep track instant actions for all users related to these softwares. (Only the latest action for distinct users for each software)
So I designed sth. like that:
Table: SW_X_DATA_ARCHIVE
Columns :
UserID
Data_Date
SW_A_ActionID
Table: SW_X_INSTANT_DATA
Columns:
UserID
Data_Date
SW_X_ActionID
When a new data comes, it updates INSTANT_DATA table's related row if that UserID exists, inserts new row with UserID and data if not. Then inserts the same data to DATA_ARCHIVE table.
The question is: Is there a better way for this kind of work? Views maybe?
(I've read sth. about materialized views but not sure how to use it here.)
Thanks
Only the latest action for distinct users for each software
Your INSTANT table should have a unique composite key on (USERID,SOFTWAREID) so that it is not possible to have more than one row relating to a user's use of a software.
The ARCHIVE table does not require such a unique key or constraint.
You would insert into INSTANT if a row for (USERID, SOFTWARE) does not exist, or update the row if it already exists.
Typically, an insert/update trigger would be placed on the INSTANT table, to insert a row into ARCHIVE whenever a change happens to INSTANT.
EDIT: alternatively, you could maintain a single table, and have a view that selected only the latest action per user per software. You'd need to timestamp every action and place a composite index (non-unique) on (USERID,SOFTWAREID). The decision on which approach to take might be based on relative performance. I would tend to favor the trigger if the Latest Action information was needed frequently.

Extract data from two tables of DB2 database and load into a temporary table

I am creating an informatica workflow which can extract data from two tables of DB2 database and load into a temporary table. Suppose the two source tables name are Account (Parent) and Activities (Child). They have 1:M relationship. Means an Account can have many Activities (Account.PK = Activities.FK). Activities table has two columns- first 'Type' whose value could be 'Paid', 'Will-Pay' or 'Not-Paid'.And second column is 'Created_Date' datetime datatype, whenever you create new activity record, date and time would get stamp in this field. Now, condition to load data in temporary table is - "For an Account record, it would 1st check in Activities table for today's Paid activities (Type = Paid). If it finds more than one paid activities, then it would pick the Latest created one (Created_Date column) out of them. If there is no Paid activity record for the Account, then it would pick latest created 'Will-Pay' activity." Means, it should pick latest Paid activity for today (Sysdate) for an Account, if it is not present then only It will pick latest Will-pay activity for today. Please help me to understand how I can implement this logic in Informatica workflow and which transformations I should use and how? Thanks alot. Kindly help.
Best way to do it on SQL cause realize business logic on ETL it's not good. But if you insist it can be created by many ways. As example:
With SQL override
You can create 3 lookup transformation for Activities table with overrided SQL (and columns too) and one expression transformation for condition.
Lookup to find more than one 'paid' activities accounts
Lookup to find last 'paid' activity per account
Lookup to find last 'will pay' activity per account
Expression to return correct Activities key based from 1-3 lookup results
Without SQL override you need to recreate similar logic with filter, aggregator, joiner transformations.

Resources