|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Oracle Update-question
I am updating a table with a value used in another table. Now my Oracle skills are slowly coming back up to speed, but would appreciate any help on this:
Baan Application: UPDATE ttcibd001100 a SET a.t$seab=(SELECT b.t$otbp from ttdipu001100 b where b.t$item=a.t$item and b.t$otbp is not null and substr(a.t$item,10,6)>'53-A00000.0000' and substr(a.t$item,10,6)<'53-A15006.6250' ) / Following a similar example in oracle sql book page 292-293: example: BEGIN UPDATE emp e SET sal=(SELECT sal * 0.90 from emp m where e.mg =m.empno) where mg is not null END; The code gets hung up on the b.t$otbp. Objective: Set value of ttcibd001100.seab = ttdipu001100.otbp based on an range of items: and substr(a.t$item,10,6)>'53-A00000.0000' and substr(a.t$item,10,6)<'53-A15006.6250' Gets error: cannot update ("BAAN"."TTCIBD001100"."T$SEAB") to NULL |
|
#2
|
|||
|
|||
|
Porbably the t$seab column has a not null constraint and the subselect returns an empty set.
|
|
#3
|
|||
|
|||
|
Updateing value in one table with another in a diff table.
Thanks for your replys: I did however, put in the following condition so that if NULLS where hit, they would not get through:
UPDATE ttcibd001100 a SET a.t$seab=ttdipu001100.otbp WHERE EXISTS(Select b.t$item from ttdipu001100 b WHere b.t$item=a.t$item and b.t$otbp is not null and substr(a.t$item,10,14)>='53-A00000.0000' and substr(a.t$item,10,14)<='53-A016088.6250' ) / However, it still errors indiciating that the a.t$seab=ttdipu001100.otbp 'ttdipu001100.0tbp is a value the SQLPLUS does not understand. I changed the script to : UPDATE ttcibd001100 a SET a.t$seab='SUP000102' WHERE EXISTS(select b.t$item,b.t$otbp from ttdipu001100 b WHERE b.t$item=a.t$item /* Update group 1*/ AND substr(b.t$item,10,14)>='53-A00000.0000' AND substr(b.t$item,10,14)<='53-A01608.6250' ) / And things get done correctly. But this is a straightforward hard update rather than a dynamic update. Anyone have any other ideas? Thanks to all! Jeff Laatsch |
|
#4
|
|||
|
|||
|
I noticed that your parameters in the sub-query changed a little from your first post to your last... did you try
UPDATE ttcibd001100 a SET a.t$seab=(SELECT b.t$otbp from ttdipu001100 b where b.t$item=a.t$item and b.t$otbp is not null and substr(b.t$item,10,6)>'53-A00000.0000' and substr(b.t$item,10,6)<'53-A15006.6250' ) / substituting a.t$item with b.t$item? |
|
#5
|
|||
|
|||
|
Oracle don't understand this value, use to_number or to_char conversion. Instead where a > c and a < d use where a between c and d.
|
|
#6
|
|||
|
|||
|
give some credit to cursors
declare
cursor c is select t$otbp,t$item from ttdipu001100 where t$otbp is not null and substr(t$item,10,14) between '53-A00000.0000' and '53-A016088.6250' ; begin for v in c loop UPDATE ttcibd001100 SET t$seab=v.t$otbp where t$item=v.t$item; --- eventualy insert here a commit after every x (depends on your log files) updates end loop; commit; end; |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Oracle Update-question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|