943,981 Members | Top Members by Rank

Ad:
  • Oracle Discussion Thread
  • Unsolved
  • Views: 1759
  • Oracle RSS
Nov 16th, 2008
0

problem with update

Expand Post »
I have written my simple query using update and in a file with a .sql extension. However, I cant seem to update my table and yet at the end of the input it shows me 1 row updated I would also want to know how I can do 2 updates simultaneously. Thanks. Here is the code
Oracle Syntax (Toggle Plain Text)
  1. accept ID prompt 'Enter Old ID:'
  2. accept ID prompt 'Enter New ID:'
  3. accept Name prompt 'Name:'
  4.  
  5. UPDATE table_one
  6. SET ID=REPLACE(ID,'&ID','&ID')
  7. WHERE Name='&Name';
Last edited by joshmo; Nov 16th, 2008 at 8:45 am.
Similar Threads
Reputation Points: 19
Solved Threads: 20
Posting Whiz in Training
joshmo is offline Offline
280 posts
since Oct 2007
Dec 24th, 2008
0

Re: problem with update

Hi

Your script should update the record assuming the ID and name exist. Try a commit after the update to save the change.

UPDATE table_one
set ID=replace(ID,'&ID','&ID')
where Name='&Name';
commit;
select * from table_one; -- will show your change

Don't perform the update in one sqlplus window and try and view the results in another as the results won't show until you've issued a commit statement.

Hope it helps.

Merry Christmas
Alistair
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
alit2002 is offline Offline
52 posts
since Dec 2006
Mar 6th, 2009
0

Re: problem with update

To do 2 updates or more you only have to add your lines to the script. But be sure to make a commit at the bottom as alit2002.

You can add as many querys as you need.

If you have just inserted data, then you may need to put a commit after every query.

Hope it helps
Reputation Points: 11
Solved Threads: 1
Newbie Poster
vimotaru is offline Offline
17 posts
since Oct 2008
Mar 9th, 2009
0

Re: problem with update

once you COMMIT that will be reflected in the database table.

if you exit without commit all the uncommitted transactions will be rolled back.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Mar 10th, 2009
0

Re: problem with update

I was just reading your code and I have a question:

Are the variables names ok?
Maybe you need to name the 'ID' vars different. IDo and IDn for example.

Maybe the problem with the update is that the 'replace' cannot do his job.

If that is an errata...well... try with SO parameters.
Hope it works.
Reputation Points: 11
Solved Threads: 1
Newbie Poster
vimotaru is offline Offline
17 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Oracle Forum Timeline: Limit days stored in DB
Next Thread in Oracle Forum Timeline: update a record on load





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC