Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old May 20th, 2004, 04:51 PM
jefflcexp jefflcexp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 jefflcexp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old May 21st, 2004, 02:38 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
Porbably the t$seab column has a not null constraint and the subselect returns an empty set.

Reply With Quote
  #3  
Old May 26th, 2004, 11:23 AM
jeffl2rp jeffl2rp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 jeffl2rp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old May 26th, 2004, 11:46 AM
Kraeg Kraeg is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Schaumburg, IL
Posts: 20 Kraeg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #5  
Old May 27th, 2004, 08:53 AM
Tomasz Morus Tomasz Morus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 20 Tomasz Morus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 28 sec
Reputation Power: 0
Send a message via ICQ to Tomasz Morus
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.

Reply With Quote
  #6  
Old June 1st, 2004, 12:16 PM
utecistu utecistu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 16 utecistu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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;

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle Update-question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway