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

Upadting a numeric field

Status
Not open for further replies.

ashab02

Programmer
Jun 28, 2005
87
GB
Hello

I am wanting to update a numeric field to that it displays the value divided by 100

I have selected the field using the following query


SELECT NUMERIC_VALUE, (NUMERIC_VALUE/100) FROM DETAILS.

Its displays the correct data but I also want to maybe write a where clause which checks if the field is already in the correct format, if this is the case then I would like to exclude them records for the update.

Any help appreciated.
 
Suppose there are two values: 2.00 and 200.00.

How would ya determine correct "format" in these cases?

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Hello

I'm safe to assume they will all be in 200.00 format, my other question is that when I perform that query how do I format the columns so its rounded to two decimal place?

Thanks for the help so far
 
I think the idea of updating the field is a bad plan, unless that will be done at the same time as an application conversion so that all new data goes into the field already divided by 100 at the same time.

The way you asked the question implies that you will have mixed values in the table some already converted and some not, and you probably know the data and where it is coming from better than anybody else, but as Vongrunt pointed out if a value was previously 20,000 and was formatted per your update it would now be 200.00. Or it could have been 2.00 originally and need to become .02.

Formatting of values should be done by the UI on the way out or on the way in, but mixing things up so that the data is still coming in in whole numbers and then converted to percents later seems like a plan that will lead to problems. Any query that reports on the data before you run the conversion job will be wrong. Any report that runs before the conversion job will be wrong.

Consider just running the formatting on the front ends, or change everything over at the same time.

Just a thought,
Dalton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top