If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Equivalent to the "Ceiling" function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-01-04, 12:04
macca macca is offline
Registered User
 
Join Date: Apr 2003
Posts: 54
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,
Reply With Quote
  #2 (permalink)  
Old 11-01-04, 12:52
fprose fprose is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 11-02-04, 03:48
macca macca is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 08-10-09, 05:55
pretygirl pretygirl is offline
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old 08-13-09, 08:52
ceinma ceinma is offline
Registered User
 
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).
________________________________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On