SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast imacoding's Avatar
    Join Date
    Jun 2004
    Location
    Rochester NY
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    keeping a decimal from rounding with data from a procedure

    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 07:53.

  2. #2
    SitePoint Addict silent's Avatar
    Join Date
    Jun 2004
    Location
    Roaming North America
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imacoding
    I am trying to keep a decimal from rouding in sql 2000 when coming in from a procedure, any help?
    Uh, this is the MySQL forum, but, whatever...

    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

  3. #3
    SitePoint Enthusiast imacoding's Avatar
    Join Date
    Jun 2004
    Location
    Rochester NY
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Quote Originally Posted by silent
    Uh, this is the MySQL forum, but, whatever...

    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 that
    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.

  4. #4
    SitePoint Addict silent's Avatar
    Join Date
    Jun 2004
    Location
    Roaming North America
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imacoding
    Well i am not actually doing the sql part of this, my colleague does that
    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?

    Thanks,

    jay

  5. #5
    SitePoint Enthusiast imacoding's Avatar
    Join Date
    Jun 2004
    Location
    Rochester NY
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by silent
    OK. What language are you using? Could you post some code to look at?

    Thanks,

    jay

    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.

  6. #6
    SitePoint Addict silent's Avatar
    Join Date
    Jun 2004
    Location
    Roaming North America
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imacoding
    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.

    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

  7. #7
    SitePoint Enthusiast imacoding's Avatar
    Join Date
    Jun 2004
    Location
    Rochester NY
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [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.

  8. #8
    SitePoint Addict silent's Avatar
    Join Date
    Jun 2004
    Location
    Roaming North America
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #9
    SitePoint Addict silent's Avatar
    Join Date
    Jun 2004
    Location
    Roaming North America
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Plus, is the datatype decimal(6,2) in the table, or in the stored procedure?

  10. #10
    SitePoint Enthusiast imacoding's Avatar
    Join Date
    Jun 2004
    Location
    Rochester NY
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by silent
    Plus, is the datatype decimal(6,2) in the table, or in the stored procedure?
    its in the stored procedure.

  11. #11
    SitePoint Addict silent's Avatar
    Join Date
    Jun 2004
    Location
    Roaming North America
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imacoding
    its in the stored procedure.
    What's the datatype in the table?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •