I am trying to keep a decimal from rouding in sql 2000 when coming in from a procedure, any help?
| SitePoint Sponsor |
I am trying to keep a decimal from rouding in sql 2000 when coming in from a procedure, any help?
Last edited by imacoding; Aug 4, 2004 at 08:53.


Uh, this is the MySQL forum, but, whatever...Originally Posted by imacoding
Do you mean when you get the decimal BACK from the procedure, or when you are IN the actual procedure? If latter, have you tried the CONVERT functions (or CAST), making sure you use the correct precision and scale?
jay
Well i am not actually doing the sql part of this, my colleague does thatOriginally Posted by silent
end, i make sure it works.
We have been having difficulty when entering a
0000.00 decimal and hitting the submit button it returns a rounded result.
Sorry about kind of off topic post but we are little stuck.
I knew i could at least get an opinion here so... any help is much appreciated.


OK. What language are you using? Could you post some code to look at?Originally Posted by imacoding
Thanks,
jay
Originally Posted by silent
I believe we have the problem fixed, we used a (varchar) and it seems to be working well. I will get some of the code and post it sometime today, maybe it will help someone out in the future.
The actual pages are writen in C# through an infragistics interface.


OK. I question the use of varchar datatype when storing decimal(6,2) data, but if that's what you want to do, OK.Originally Posted by imacoding
The reason it's not the greatest idea is because you ideally want to use the database to enforce data integrity, not your application code. If the data going in to the field should be decimal(6,2), then the database should enforce whether the data being inserted is of the required type. Save application validation for more complex or business-rule type validation, for instance, checking to see whether the number lies in a valid range of numbers (although, with SQL 2000, a CHECK CONSTRAINT would be appropriate for use there as well).
I look forward to seeing your code and perhaps giving you some more advice, if you'll let me!
cheers,
jay
[QUOTE=silent]OK. I question the use of varchar datatype when storing decimal(6,2) data, but if that's what you want to do, OK.
Here is the issue we were having.
when we try and submit a vlaue through a stored procedure say 8.55 that it enters in 9 even though we have the decimal field set to (2,5) if we enter in 8.55 through enterprise manager then it works fine.


It should be decimal(5,2), not (2,5).
(5,2) means five overall places, 2 to the right of the decimal point.
(2,5) doesn't make sense, as it means 2 overall places, 5 to the right of the decimal point.


Plus, is the datatype decimal(6,2) in the table, or in the stored procedure?
its in the stored procedure.Originally Posted by silent


What's the datatype in the table?Originally Posted by imacoding
Bookmarks