Home » SQL & PL/SQL » SQL & PL/SQL » simple sql question (Oracle 9.2)
simple sql question (Oracle 9.2) [message #202361] Thu, 09 November 2006 06:11 Go to next message
runett
Messages: 2
Registered: November 2006
Location: Norway
Junior Member
I try to find a way to insert the value '0' into a column(VARCHAR2) in all rows in a table, but i do not want to overwrite already filled values, I try this:

update tablename set fieldname='0' where fieldname = null;

But this does not work...
Anyone who knows how to do this?
Re: simple sql question (Oracle 9.2) [message #202362 is a reply to message #202361] Thu, 09 November 2006 06:14 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member
hi,

it should be.
 update table_name set col_name='0' where col_name is null


regards,
Re: simple sql question (Oracle 9.2) [message #202363 is a reply to message #202362] Thu, 09 November 2006 06:21 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
Or
UPDATE table_name SET column_name = nvl(column_name,'0');
Re: simple sql question (Oracle 9.2) [message #202364 is a reply to message #202362] Thu, 09 November 2006 06:21 Go to previous messageGo to next message
runett
Messages: 2
Registered: November 2006
Location: Norway
Junior Member
thanks! Smile
Re: simple sql question (Oracle 9.2) [message #202379 is a reply to message #202363] Thu, 09 November 2006 07:24 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
JRowbottom wrote on Thu, 09 November 2006 13:21
Or
UPDATE table_name SET column_name = nvl(column_name,'0');


Nah, don't update rows you don't want to update!
Previous Topic: Formatting Data and inserting into a table
Next Topic: Creating a Total per hour
Goto Forum:
  


Current Time: Fri Dec 09 23:00:32 CST 2016

Total time taken to generate the page: 0.12771 seconds