GeppoDarkson
Programmer
Hi to all,
may I update a field that is part of the "ON" clause of a MERGE INTO statement?
I have two tables for temperature data: TReal And TTemp with the same structure:
IdStation, DT_Hour, Measure, Rank
I want to insert in TReal the missing records of TTemp (same IdStation & DT_Hour)
and
to Update Measure and Rank Of records with same IdStation & DT_Hour but TReal.Rank <= TTemp.Rank
The statement:
Says that is an Ora-00904 error (no field) on the 3rd row at R.Rank.
It seems that this is caused by the Update clause:
When I create a new field TReal.Rank2 and upate this instead of Rank everithing works.
So, may I update a field that is part of the "ON" clause of a MERGE INTO statement?
Thank You.
Geppo Darkson.
may I update a field that is part of the "ON" clause of a MERGE INTO statement?
I have two tables for temperature data: TReal And TTemp with the same structure:
IdStation, DT_Hour, Measure, Rank
I want to insert in TReal the missing records of TTemp (same IdStation & DT_Hour)
and
to Update Measure and Rank Of records with same IdStation & DT_Hour but TReal.Rank <= TTemp.Rank
The statement:
Code:
Merge into TReal R
Using (Select Id,IdSens,Dt,Valore,XXXX From TTEMP) T
ON (R.IdStation = T.IdStation and R.Dt_Hour=T.Dt_Hour And [COLOR=red]R.RANK[/color] <= T.RANK)
When Matched Then Update Set R.Measure=T.Measure , [COLOR=red]R.RANK[/color] = T.Rank
When not Matched Then Insert(IdStation Dt_Hour ,Measure,Rank) Values (T.IdStation ,T.Dt_Hour ,T.Measure,T.Rank)
Says that is an Ora-00904 error (no field) on the 3rd row at R.Rank.
It seems that this is caused by the Update clause:
When I create a new field TReal.Rank2 and upate this instead of Rank everithing works.
Code:
Merge into TReal R
Using (Select Id,IdSens,Dt,Valore,XXXX From TTEMP) T
ON (R.IdStation = T.IdStation and R.Dt_Hour=T.Dt_Hour And [COLOR=red]R.RANK[/color] <= T.RANK)
When Matched Then Update Set R.Measure=T.Measure , [COLOR=green]R.RANK2[/color] = T.Rank
When not Matched Then Insert(IdStation Dt_Hour ,Measure,Rank) Values (T.IdStation ,T.Dt_Hour ,T.Measure,T.Rank)
So, may I update a field that is part of the "ON" clause of a MERGE INTO statement?
Thank You.
Geppo Darkson.