Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Loosing decimal values while selecting in Oracle

Loosing decimal values while selecting in Oracle

Scheduled Pinned Locked Moved Database
sharepointoraclequestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sandhya14
    wrote on last edited by
    #1

    Hi all, here is my SP create FUNCTION fn_Ceiling ( Source IN DECIMAL ) RETURN DECIMAL as DecDiff DECIMAL(16,3); Ceiling DECIMAL(16,3); Source1 DECIMAL; BEGIN SELECT NVL(Source, 0) INTO Source1 FROM DUAL; SELECT Source1 - FLOOR(Source1) INTO DecDiff FROM DUAL; SELECT FLOOR(Source) + case WHEN DecDiff between 0.000 and 0.250 THEN 0.000 WHEN DecDiff between 0.250 and 0.750 THEN 0.500 WHEN DecDiff between 0.750 and 1.000 THEN 1.000 else DecDiff end INTO Ceiling FROM DUAL; return Ceiling; END; / It is created... but if i execute the function am not getting the correct value ex:- select fn_ceiling(1.75) from dual; am getting the result as 1 (actaul result should be 1.500) Dnt know what i did wrong?

    M 1 Reply Last reply
    0
    • S sandhya14

      Hi all, here is my SP create FUNCTION fn_Ceiling ( Source IN DECIMAL ) RETURN DECIMAL as DecDiff DECIMAL(16,3); Ceiling DECIMAL(16,3); Source1 DECIMAL; BEGIN SELECT NVL(Source, 0) INTO Source1 FROM DUAL; SELECT Source1 - FLOOR(Source1) INTO DecDiff FROM DUAL; SELECT FLOOR(Source) + case WHEN DecDiff between 0.000 and 0.250 THEN 0.000 WHEN DecDiff between 0.250 and 0.750 THEN 0.500 WHEN DecDiff between 0.750 and 1.000 THEN 1.000 else DecDiff end INTO Ceiling FROM DUAL; return Ceiling; END; / It is created... but if i execute the function am not getting the correct value ex:- select fn_ceiling(1.75) from dual; am getting the result as 1 (actaul result should be 1.500) Dnt know what i did wrong?

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Not sure with Oracle but I would look at Source1, no presision is declared. Also your case logic is going to cause a problem with 25 and 75. It meets 2 conditions is should be

      WHEN DecDiff between 0.000 and 0.250 THEN 0.000
      WHEN DecDiff between 0.251 and 0.750 THEN 0.500
      WHEN DecDiff between 0.751 and 1.000 THEN 1.000

      Never underestimate the power of human stupidity RAH

      S 1 Reply Last reply
      0
      • M Mycroft Holmes

        Not sure with Oracle but I would look at Source1, no presision is declared. Also your case logic is going to cause a problem with 25 and 75. It meets 2 conditions is should be

        WHEN DecDiff between 0.000 and 0.250 THEN 0.000
        WHEN DecDiff between 0.251 and 0.750 THEN 0.500
        WHEN DecDiff between 0.751 and 1.000 THEN 1.000

        Never underestimate the power of human stupidity RAH

        S Offline
        S Offline
        sandhya14
        wrote on last edited by
        #3

        If i add the presision also the same result..:-(

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups