Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2003
    Posts
    54

    Unanswered: Equivalent to the "Ceiling" function

    Does anyone know if there is an equivalent to the "CEILING" function, available in SQL server, in Informix?

    For any Informix officionados who don't know SQL Server, the ceiling function rounds up a number to the next whole number, regardless of the decimal portion of a number. For example

    SELECT CEILING(4.2) --returns 5
    --or--
    SELECT CEILING(5) --returns 5
    --or--
    SELECT CEILING(5.2 + 7.1) --returns 13

    I need equivalent functionality and couldn't find any hints in the informix docs.

    Many thanks,

  2. #2
    Join Date
    Apr 2003
    Location
    Phoenix, AZ
    Posts
    177
    There is no built-in function but you could write your own. Simple example:

    drop function ceiling(decimal);

    create function ceiling(invalue decimal) returning decimal;
    define retvalue decimal;
    if (invalue = trunc(invalue,0))
    then
    return invalue;
    else
    return trunc(invalue,0)+1;
    end if
    end function;
    Fred Prose

  3. #3
    Join Date
    Apr 2003
    Posts
    54

    Smile

    Thanks for that. As informix is a bit of a new area for me, I didn't think of that! I tried using dbaccess to create this function and it gave me a syntax error so I'm going to have to do a bit more learning around the subject before I can implement this solution. In the meantime I'll implement a fix by writing a similar function in c# in my data tier. Not pretty, I know, but thanks for the help.

  4. #4
    Join Date
    Aug 2009
    Posts
    2
    I was registered at your forum. I have printed the test message. Do not delete, please.



    gratuit pour mobile sonnerie portable mp3 - Sonnerie portable MP3 est en effet un pouvoir de l'innovation technologique. Êtes-vous familier avec cette sonnerie portable?gratuit pour mobile sonnerie portable mp3

  5. #5
    Join Date
    Apr 2007
    Location
    Jundiai / SP - Brasil
    Posts
    311
    Yes Informix have a "CEILING" function, but only after the version 11.10...

    Check the links bellow...

    CEIL Function

    IBM Informix Dynamic Server v11.50 Information Center
    ________________________________________
    César Inacio Martins
    Jundiai / SP - Brasil
    http://www.imartins.com.br/informix - em Português
    http://www.imartins.com.br/informix - English (translated by Google).
    ________________________________________

Posting Permissions

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