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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace null numeric fields with space not even 0

Status
Not open for further replies.

nirajj

Programmer
Mar 12, 2003
103
US
I would like to replace the numeric field in cursor with space where the value is null.

I tried something like
REPLACE ALL fieldname WITH VAL('') FOR ISNULL(fieldname)

I tried several options but just cant get it to be space. I always endup getting 0.

REPLACE ALL fieldname WITH '' FOR ISNULL(fieldname) gives data type mismatch error. Which is obvious.

Is it possible to replace numeric fields with space. Or no value. Not even zero.

Thanks !
 
Got it working.
SET DECIMALS TO 0
VAL('') returns nothin...
 
I dont think taht you can store space in filed that is numeric format.

If you wont have space in field that should contain numbers so change field format to Character and store number this way:

table.field=str(_x,10,2)

readind data from field:

_x=val(table.field)
 
Well.. I thought set decimal worked... but it actually doesnt...

And the only problem is I cant change the field to character. I can create another cursor with character field and transfer data. But that means overhead on the performance. And I am actually trying to reduce the run time.

bon011,

The problem is that some values in the table are numeric and some have .null. I want to replace .null. with nothin. No value atall, not even 0. Because zero is also some value.

I actually just want the .null. to display nothing. I want it all empty. I wonder if there is any way out?
x = .null.
str(x,10,2) wont work. :(.....

 
insert this code
result=iif(isnull(x),"",str(x,10,2))
 
As long as it is a cursor from a table and not a remote view, you should be able to do:

BLANK ALL FIELDS fieldname FOR IsNull(fieldname)

Which will replace the field with 'nothing' instead of the default empty value e.g., 0.00 for numeric and {//} for date.

If there is more than one field you want to blank, I would do a scan/endscan in case one field is null, but another field in the same record isn't:
Code:
SCAN
   IF ISNULL(fieldname1)
      BLANK FIELDS fieldname1
   ENDIF
   IF ISNULL(fieldname2)
      BLANK FIELDS fieldname2
   ENDIF
   .
   .
   .
ENDSCAN
Dave S.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top