Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF THEN

Status
Not open for further replies.

Stevennn

Programmer
Apr 4, 2007
52
US
I have a field that might contain NULL

How can i incert there word NONE???


IF cc_accd = NULL then 'NONE'???????
 
russski,

how about

Code:
UPDATE <TABLE_NAME>
   SET <FIELD_NAME> = 'NONE'
 WHERE <FIELD_NAME> IS NULL

If you post the code to create the table in question and one or two rows of data, then I can be more specific.

Note that this assumes that field is a character type. If it's numeric, this won't work.

Let us know how you get on.

Regards

T

Grinding away at things Oracular
 
My field is NUMERIC
cc_ctr
1234
<<<<<<<NULL
3456
4567
<<<<<<NULL I want blank to be replaced with NONE
6787
8980
8090

THANK_YOU
 
Russki,

A NUMERIC field cannot contain a non-numeric value such as "NONE". In Oracle, NULL represents the absence of value for all data types. You can assign NULL to any nullable receiving field in Oracle. To assign "NONE" to a field to represent the absence of a value is poor form in the Oracle world...there are many reasons NOT to use "NONE" and many reason to use NULL. Oracle has a full range of operators to deal with evaluating and manipulating NULLS; evaluating the expression value, "NONE", is inefficient compared to counterpart evaluations and manipulations of NULL.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
I just checked it's not NUMERIC it is VARCHAR2!!!

 
Okay, so you have the ability to store "NONE" in "cc_ctr", but that still doesn't make it good form. All of the principles I mentioned in my previous reply still apply.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
The is a couple of ways to do this.

select nvl(my_col,'NONE') my_col
from my_table;

of if you are using sql*plus then

SET NULL NONE

Bill
Oracle DBA/Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top