Trigger Problem [message #249808] |
Thu, 05 July 2007 23:52 |
jainarayan5484
Messages: 38 Registered: August 2006 Location: DELHI
|
Member |
|
|
I Have a Table Like AdjustSize and its Descriptiotn is given Bellow;
SQL> Desc Adjustsize;
Name Null? Type
----------------------------------------- -------- ------
RECORD_NO NOT NULL NUMBER
SR_NO NOT NULL NUMBER
ITEM_SIZE NUMBER
ITEM_CLASS VARCHA
ITEM_GROUP VARCHA
ITEM_QUALITY VARCHA
BK_EXISTING NUMBER
BK_CAL_BASIS VARCHA
BK_PER NUMBER
BK_PROPOSED NUMBER
MTR_PER_TON NUMBER
FREIGHT_BK NUMBER
DISC_BK NUMBER
COIN_BK NUMBER
Its Records is as:
SQL> Select * from Adjustsize where Record_no=34;
Record no SR_NO SIZE Class Group Quality BK_EXISTING BK_PER BK_PROPOSED MTR_PER_TON
--------- ------ ----- ----- ---- ------ -------- ------ ---------- ----------
34 1 100 L BK SS 361 -1000 351.5 106
34 2 100 L BK SS3 366 0 356.5 106
Now I Want To Calculate BK_ProPosed Column Value by Formula of
ROUND(((MTR_PER_TON*NVL(BK_EXISTING,0))+NVL(BK_PER,0))/MTR_PER_TON,2)
But this Formuala is For Only Sr_no=1 and User Wants BK_Proposed of Sr_no=2 is Calculated by Sr_no=1 by
Adding 5 more
I explane Breifly as
Bk_Proposed of sr_no=1 is Equal to ROUND(((MTR_PER_TON*NVL(BK_EXISTING,0))+NVL(BK_PER,0))/MTR_PER_TON,2);
Bk_Proposed of Sr_no=2 is Equal to (Bk_Proposed of Sr_no=1 + 5)
it is sure that Table Contain Only Two Records For a Record_no ;
How Can I Do by Using Trigger pls help me.
|
|
|
|
Re: Trigger Problem [message #249819 is a reply to message #249808] |
Fri, 06 July 2007 01:01 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
What should happen if someone change sr_no?
How can a trigger see sr_no=1 if sr_no=1 is not yet committed?
In short, you generally can't do it with a trigger unless you are in a very specific case like only one session handles every rows of a record_no.
Regards
Michel
|
|
|