DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Oracle (http://www.daniweb.com/forums/forum129.html)
-   -   problem with update (http://www.daniweb.com/forums/thread157672.html)

joshmo Nov 16th, 2008 8:43 am
problem with update
 
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
accept ID prompt 'Enter Old ID:'
accept ID prompt 'Enter New ID:'
accept Name prompt 'Name:'

UPDATE  table_one
set ID=replace(ID,'&ID','&ID')
where Name='&Name';

alit2002 Dec 24th, 2008 7:32 am
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

vimotaru Mar 6th, 2009 9:00 am
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

debasisdas Mar 9th, 2009 3:00 am
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.

vimotaru Mar 10th, 2009 9:55 pm
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.


All times are GMT -4. The time now is 12:37 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC