Pages

Tuesday, March 10, 2020

Oracle forms Diff Between Post – Change, When-Validate-Item

Diff Between Post – Change, When-Validate-Item

Post-Test-Item” Trigger fires every time when focus moves from one item to another item.

“Post – Change”, ”When-Validate-Item” à Both Triggers Have the same functionality except
that Post-Change doesn’t fire in one case when existing value is changed to NULL While in that case When-Validate-Item trigger fires. And all other functionality of these both triggers are same in the manner that both fires when the status of the item becomes ‘CHANGED’. If status remains ‘UNCHANGED’ then these both trigger doesn’t fires.

Yasser

Thursday, March 5, 2020

Oracle PIVOT

SELECT * FROM DailyIncome
VendorIdIncomeDayIncomeAmount
SPIKEFRI100
SPIKEMON300
FREDSSUN400
SPIKEWED500
SPIKETUE200
JOHNSWED900
SPIKEFRI100
JOHNSMON300
SPIKESUN400
JOHNSFRI300
FREDSTUE500
FREDSTUE200
SPIKEMON900
FREDSFRI900
FREDSMON500
JOHNSSUN600
SPIKEFRI300
SPIKEWED500
SPIKEFRI300
JOHNSTHU800
JOHNSSAT800
SPIKETUE100
SPIKETHU300
FREDSWED500
SPIKESAT100
FREDSSAT500
FREDTHU800
JOHNSTUE600

Query (A)

SELECT * FROM DailyIncome
PIVOT (SUM (IncomeAmount) FOR IncomeDay IN
([MON],[TUE],[WED],[THU],[FRI],[SAT],[SUN])) AS AvgIncome

VendornameMonTueWedThuFriSatSun
AMIT475150475300200100400
PANKAJ360600920800300800600
VINAY500350500800900500400

Tuesday, March 3, 2020

Oracle tree hierarchical query

In a hierarchical querytraverse the tree from the branch level to the top

select *
from EMP
start with EMPNO = :x
connect by prior MGR = EMPNO;

Oracle tree queries

SELECT parent_COST_CENTER_ID,COST_CENTER_ID,sum(parent_price) parent_price,lVL
FROM(
        SELECT parent_COST_CENTER_ID,COST_CENTER_ID,
            (TOTAL_ACTUAL_DEBIT) parent_price,lVL
        FROM COST_JOURNALTREES
        WHERE BRANCH_ID = 216
    ) t
GROUP BY parent_COST_CENTER_ID,COST_CENTER_ID,LVL
/

select DISTINCT
   connect_by_root parent_COST_CENTER_ID rootParent,  
   PARENT_SUM,
   COST_CENTER_ID,
   TOTAL_ACTUAL_DEBIT,
   prior TOTAL_ACTUAL_DEBIT prior_TOTAL_ACTUAL_DEBIT,
   level lvl
 FROM
   COST_JOURNALTREES
   WHERE BRANCH_ID = 216 --AND cost_center_id = 407--IN (427,409,407)
   START WITH PARENT_COST_CENTER_ID IS NOT NULL
   connect by prior COST_CENTER_ID = parent_COST_CENTER_ID
/