Rounding up in oracle 9i

Dear all;
I am looking for the best way to round up in all cases. In otherwords, if the result is 2.3333333 then it would round up to 3, or if the result is just 0.5, it should just round up to 1 or if the result is 1.1, it should round up to 2, the decimal place shouldnt matter. all help will greatly be appreciated.

Have a look at the CEIL function:
SQL> select ceil(2.333333) from dual;
      CEIL(2.333333)
                   3
SQL> select ceil(0.5) from dual;
           CEIL(0.5)
                   1
SQL> select ceil(1.1) from dual;
           CEIL(1.1)
                   2
SQL> select ceil(3) from dual;
             CEIL(3)
                   3
SQL> select ceil(-3.1) from dual;
          CEIL(-3.1)
                  -3
SQL> select ceil(-2.9) from dual;
          CEIL(-2.9)
                  -2

Similar Messages

  • Reg : Rounding Issue in Oracle BI Publisher

    Hi all,
    In BI Publisher am trying to view the data in XML and the source is Oracle BI(for sql). Here while seeing the results am getting the values like
    <ROWSET>

    <ROW>
    <saw_0>1.42957E7</saw_0> --Here actual value is 14,295,700
    <saw_1>1.20302456E7</saw_1> -- Here actual value is 12,030,246
    <saw_2>2265454.4</saw_2>
    <saw_3>19709.0</saw_3>
    <saw_4>11632.0</saw_4>
    <saw_5>8077.0</saw_5>
    <saw_6>3.232222222222222</saw_6>
    <saw_7>6.0025</saw_7>
    <saw_8/>
    <saw_9>11632.0</saw_9>
    </ROW>
    </ROWSET>
    I want to get the results without any decimal points .
    Please help on this .
    Thanks in advance .

    Hi Kishore,
    Thanks for quick response. Here I tried to round the values by using ROUND function, as result am getting results with atleast one decimal point (I dont want that) .
    And the values 14295700 results like 1.42957E7 , Here I want the value 14295700 .

  • Spatial components are rounded up in oracle htmldb

    Hi all,
    I use the following query:
    select c.employee_id
    ,first_name
    ,vestigingsplaats
    ,salary
    ,c.geom.sdo_point.X X
    ,c.geom.sdo_point.Y Y
    from employees c
    where geom is not null;
    It uses a spatial column. This query is performing OK in sql*plus.
    Column X returns:
    X
    51.638476
    52.392363
    51.923943
    When I use the query in Oracle Htmldb it returns:
    X
    52
    52
    52
    Other number columns are not rounded(for instance 'salary) up.
    I've no clue what is causing this.
    Thanx,
    Pim

    Thanks Christian,
    Everything works OK now. It would be nice though if Oracle Explorer is mentioned in the White paper " New features in Oracle Developer Tools for Visual Studio .Net.
    Regards,
    Matthieu

  • Round funtion in oracle

    Hiii,
    How can we display 18 as 18.00 using round function. I need to display all the values upto 2 decimal places, but the whole numbers arent working!
    Vikas!

    to display numbers for the purposes of a report, etc, use to_char:
    with my_tab as (select 18 num from dual union all
                    select 2.387 from dual union all
                    select 19304.3 from dual)
    -- end of mimicking some data in a table called my_tab. See SQL below:
    select num, round(num, 2) round_num, to_char(num, 'fm99999999999990.90') char_num
    from   my_tab;
           NUM  ROUND_NUM CHAR_NUM         
            18         18 18.00            
         2.387       2.39 2.39             
       19304.3    19304.3 19304.30

  • Performance issue: stmt.execute() takes a long time when using Oracle objs

    Folks,
    I have a PL/SQL API that returns a REF CURSOR over an Oracle object that contains other objects. In the JDBC layer, when I do a stmt.execute(), it takes about 1.2s for this statement to run while the execution of the PL/SQL API in the database takes only about 100ms or so. When I connect to a database that is physically located really far away, the delta here increases (perhaps due to the network latency).
    I believe it is not as efficient to use Oracle ADTs in conjunction with JDBC. However, not using an Oracle object and replacing that with a bunch of linear arrays is not really an option for me considering the amount of change involved and what a maintenance nightware that would be. At the same time, I need to get this to perform better. Any thoughts?
    I suspect that there are a number of network round trips with Oracle objects are involved. If that is infact true, what are my options?
    I use Oracle 10g, and the Oracle JDBC thin driver. Thanks.

    I have an Oracle object that has say 3 fields - number, number and number_table (indexed table of numbers). Right now, I return a REF CURSOR and do a getObject() in the java layer. But, I want to try and change this so that I return linear arrays (meaning, all these fields are not embedded in an Oracle object). Dont know if that would make things quicker but wanted to check to see if there were other alternatives.
    Also, can I define a procedure that returns an OUT parameter which is an indexed table, and then do a registerOutParameter(<index>, OracleTypes.ARRAY)? I tried that but it gives me a PLS-00306 error (wrong number of types of arguments).

  • Migrating Oracle Databases to SQL Server 2000

    Hi friends,
    I wanna to Migrating Oracle Databases to SQL Server 2000.
    But i don have idea abt that.
    could u plz help how to start and procced.
    Neeraj Goel

    Hi Neeraj,
    This forum is dedicated to Migrating from SQLServer and other third party databases to Oracle.
    Not the other way round.
    The Oracle Migration Workbench facilitates migrations to Oracle.
    Regards,
    Dermot.

  • Round and Trunc with dates

    Can i get the examples for Round and Trunc with dates?

    Hi Rahul,
    Check out this workout by Tom Kyte on TRUNC and ROUND -
    http://www.oracle.com/technetwork/issue-archive/2012/12-sep/o52sql-1735910.html
    Dont skip even a single line of it. Really useful.
    My little workout :
    Ranit>> select
      2  round(123.444) r1,
      3  round(123.999) r2,
      4  trunc(123.444) t1,
      5  trunc(123.999) t2
      6  from
      7  dual;
            R1         R2         T1         T2                                                                                                                                                                                
           123        124        123        123                                                                                                                                                                                
    Ranit>> select
      2  round(123.444,2) r1,
      3  round(123.999,2) r2,
      4  trunc(123.444,2) t1,
      5  trunc(123.999,2) t2
      6  from dual;
            R1         R2         T1         T2                                                                                                                                                                                
        123.44        124     123.44     123.99                                                                                                                                                                                
    Ranit>> select
      2  round(123.1234,2) r1, -- "Rounds upto 2 Decimal places"
      3  round(123.1266,2) r2, -- "Rounds upto 2 Decimal places"
      4  trunc(123.1234,2) t1, -- "Keeps only 2 decimal places and Truncates the rest"
      5  trunc(123.1266,2) t2  -- "Keeps only 2 decimal places and Truncates the rest"
      6  from
      7  dual;
            R1         R2         T1         T2                                                                                                                                                                                
        123.12     123.13     123.12     123.12                                                                                                                                                                                
    --"Note the difference in R2 andT2 values : In R2 there's a data round-off done but in T2 it is simple cut-off of extra decimal part"HTH
    Edited by: ranit B on Jan 26, 2013 7:24 PM

  • Rounding Errors...

    Hi everybody,
    how should I/can I handle rounding errors in Oracle.
    I'm using the LOG function of Oracle and for SELECT LOG(2,16) FROM DUAL; Oracle returns 3,99999999999999999999999999999999999998 which is incorrect. I cannot use the Round-Function cause my whole mathematical expression (written in Excel Syntax) is:
    FLOOR(LOG(x; 2); 1)
    So if I use the round function and SELECT ROUND(LOG(2,15)) FROM DUAL; would return 4 which is not correct thinking about my FLOOR(4) => 4, but the result of the mathematical expression is 3!
    Any ideas on how to deal with such problems... is there somehow a datatype to use?
    Thanks!

    user10835064 wrote:
    Thanks Max - I guess you just wanted to illustrated the problem? cause I don't see a solution there...
    Thanks Ravi - but 7 digits... can someone assure that there is no number in the world where LOG(2, x) wont return something like y.999999987389... I mean LOG(2, 15.9999990018681) is 3,99999991 so even a rounding of 7 is not enough :)...
    Maybe another question should be asked :)... can you count on this rounding error? I mean if so, than I could add 1 => FLOOR(LOG(2, x + 1)), but if I cannot count on this rounding error, than there could be wrong results if e.g. Oracle returns the correct value!I just showed the parameter usage of round, which you can use for rounding the digits.
    While comparision like round(somevalue)>=2 as you said it is not required to round the digit, you can directly do the
    somevalue>=2
    But when you want to show the o/p to an end user who doesn't need 30+digits of precision, for him you can show using the above round function.
    Ravi Kumar

  • Rounded rectangles

    Hello all,
    I've a problem with rounded rectangles in Oracle Reports.
    I've migrated the iAS installation from a Windows system to a Solaris.
    The Solaris version is:
    cat /etc/release
    Solaris 9 4/04 s9s_u6wos_08a SPARC
    Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
    Use is subject to license terms.
    Assembled 22 March 2004
    The iAS version is: 1.0.2.2.2
    The Oracle Forms and Reports are 6i version with patch 17.
    The problem is that I've reports with rounded rectangles and they aren't show correctly.
    The curves of the rectangle are converted to corners.
    In Windows installation it works fine.
    I try changing the printer definition that were Postcript with level 1 to Postcript with level 2, but it doesn't work.
    The format report is PDF and it's in Web mode.
    Why it doesn't work fine?
    There is a bug?

    Hello all,
    I've solved the problem.
    I had Developer 6i with patch 14 and I found a note that says that in patch 13 it works fine but in patch 14 doesn't work and it's solved in patch 15.
    I installed the patch 17 and now it works fine.

  • Writing rounding calc script

    I am new to business rule/clac scripts. I need to write a cacl scripts which can round the account vale to near 10. Please suggest me how and what function can be used to write this scripts.
    Thank you

    Have a look at @ROUND - http://download.oracle.com/docs/cd/E17236_01/epm.1112/esb_tech_ref/round.html
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Ln: 0653-417 /oracle/SID/oraarch// is a directory. (cannot unlink)

    Hi,
    I have to restore a system for a DRP test.
    I first deleted the /usr/sap/SID, /sapmnt/SID and /oracle/SID directories.
    Before starting the restore I have to create a symbolic link of oraarch on saparch because the mount is on oraarch. I did it with the following command :
    ln -s /oracle/SID/saparch/ /oracle/SID/oraarch/
    after executing this line, it returns the error:
    ln: 0653-417 /oracle/SID/oraarch// is a directory. (cannot unlink)
    Many thanks for your help
    Regards

    Joe Bo wrote:
    What exactly are you trying to do?
    >
    I have to create a symbolic link of oraarch on saparch
    > Somehow I suspect it has to be the other way round:
    >
    ln -s /oracle/SID/oraarch /oracle/SID/saparch
    >
    > Read the manual pages of man ln and think again about your requirement.
    >
    > Edited by: Joe Bo on Oct 12, 2011 2:26 PM
    > (typo: ln, not ls)
    Yeah,
    it is always the other way round than you think with "ln -s".
    If you ever find a system with a link "b" pointing to "a"
    you might safely assume I had may hands on it once when I had once again
    no clue which way round the parameters work.  In this case I always execute
    ln -s a b
    just to re-ensure myself
    So if the filesystem mounted is .../oraarch, saparch needs o be non-existent when executing
    ln -s /oracle/SID/oraarch /oracle/SID/saparch
    see, just some twenty executions of "ln -s a b" and you are very sure to say which way round the parameters should be.
    Volker

  • Oracle EE License - Different plattforms

    Hello guys,
    i have a question regarding the licensing model of oracle and didn't find any information about that online.
    We licensed our database mostly on "Processor Perpetual" ... over the years and providing many database we have reached round about 16 Oracle EE licensed programs on amount of CPUs.
    These 16 EE licensed programs were bought for IBM AIX over years.
    Now we have reached a point were some EE licenses are free again and we want to install some databases on Linux.
    Can we use these free EE licensed programs also for a different platform (in our case for Linux) or do we have to buy "new licensed programs" for Linux?
    I am just talking about "the licensed programs (Oracle Database EE)" not about Software Update License & Support.
    Thanks and Regards

    My understanding is you will require additional licences for the new installation in production. However, I am not an Oracle employee, a licencing expert or a lawyer, so I advise you to discuss this with your Oracle account manager.
    Cheers, APC

  • Upgrading to 11.1.1 has wiped my ipad1 of all music and videos when synching. Please help

    I am running Windows XP, have an ipad1 running IOS 5.1.1 and an ipod 5th gen 80gb video.
    I have 6,000 songs in iTunes, podcasts, books, apps and numerous movies and videos both purchased from Apple Store and some home converted mp4s.
    I upgraded to 11.1.1 5 days ago and since then, every time I have tried to sync my ipad as I add more videos, it has gone mad and on step 4 out of 5 of the synch process it hangs and then gives me a unknown error code -69 and not only does it not add any new video files, it removes existing ones that have always been there and I just get the grey dotted circle next to them now when I look at the ipad films directory.  Podcasts are fine.
    I have fully restored the ipad, I have experimented with manually managing music and videos, I have tried to add the old 'always worked before' videos back, one by one but absolutely nothing works and since I did the restore, it now won't add ANY of my music files...I just get the error -69.
    I connected my old faithful ipod instead to see what happened and exactly the same story.
    Can I roll back a version of iTunes? What can I do? It's been maddening and I have spent 2 days trying to fix it.
    Please let me know if you have any suggestions I can try. I see that many people here have had similar problems and turning wifi on the device off seemed to have helped - but I don't even have wifi on my ipod and it screwed that up.

    Hi there,
    That's a point for a huge discussion... "EPMA may already be on its way out the door"
    I thought that it is the other way round? That Oracle aims to stop using classic application and move everything to EPMA...
    Regards,
    Thanos

  • Rich Internet Applications and PL/SQL

    I am developing a database framework, specifically designed to
    run on Oracle databases, to render rich client applications
    similar to what the HTP/HTF packages offer. In this case I render
    Java Swing interfaces based on stored procedures and packages.
    What I want with this is to have a Rich Internet Application (RIA)
    totally centralized on the database. Maybe something similar to
    HTMLDB but not using HTML interfaces. I am also thinking the
    possibility to create migration routines to convert our Oracle
    Forms modules to stored procedures using this framework. The only
    requirement to run this framework is to have a database and Apache
    with MOD_PLSQL. The main objectives I want to achieve are:
    - To render "rich client" interfaces.
    - To be able to dynamically create objects.
    - Low network usage, small messages.
    - Fast user interaction.
    - Small memory footprint on the client side.
    - Must use HTTP/HTTPS.
    - Run inside any standard Browser or standalone.
    - Stateless execution based on client events.
    - Events can be conditionally triggered to avoid round trips.
    - Oracle 8.1.7+ compatibility.
    - MDI/SDI capability.
    I already have a prototype working. The renderer Applet is just
    12Kb and all objects are created dynamically using "Reflection".
    The framework has an option to establish conditions for events using
    regular expressions to avoid unnecessary round trips. Performance so
    far is good even in slow networks. Of course I still have room for
    improvement in this area. The protocol was implemented in a way that
    it can be optimized by removing redundant messages. I also implemented
    a simple dictionary compression algorithm which further reduces the
    message size. We can also use HTTP compression in Apache with MOD_GZIP
    which has a very good compression factor. The renderer Applet runs with
    Java Web Start either so the user has the option to completely ignore
    the Browser. The framework will be composed of layers, from
    communication to application. In the highest layer I will offer
    functionalities available in 4GL languages like "maintain_table(x)"
    to automatically render a maintenance form of the passed table (very
    simple example). Even in this layer the developer will also be able to
    customize all aspects of the form like colors, fonts, layout managers,
    panels, etc. I am doing this in principle as a learning, private
    project. I am still thinking about best ways to organize the APIs,
    performance, security, etc. I was wondering if there is anyone
    interested in helping me, take a look in what I have done so far,
    opinions (good or bad), etc. The code I have so far can be accessed below.
    Thanks in advance for any comment.
    https://jgr.dev.java.net/

    Your links are broken. This is not a good demonstration of your web-based development skills. Obviously this means I have not been able to look at your examples. However, I will offer three comments.
    (1) Dynamic rendering of objects is liable to translate into a slow experience for the user. Anyone who's migrated client/server Oracle Forms to web-deployed Forms will know what I mean. And Oracle have put person-years of effort into optimising the rendering of their Forms applet.
    (2) Doing a GUI in Java Swing is the easy bit. The hard stuff resides in the transaction management that Forms does for us. Again the amount of effort Oracle have put into JDeveloper's ADF packages is a testament (and a warning).
    (3) I suppose you will say that are going to put all that stuff into database stored procedures. But that merely relocates the complexity rather than answering it. Furthermore a lot of the benefit users derive from rich client applications (as opposed to HTML forms) is not due to the superior aesthetic experience of using Windows widgets. Rather it is the embedded business logic (complex data validation, event triggers, etc.) which means the gets instantaneous responses to their input. That's a lot of complexity to render on the fly.
    I am also thinking the possibility to create migration routines to
    convert our Oracle Forms modules to stored procedures using this framework. Good luck!
    Cheers, APC

  • Manipulate BLOB column data

    Hi,
    I've database Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    I need help on manipulating BLOB column data. It is storing .msg file. I want to modify its 'Subject:' line. Below query gives me position of Subject line but when I'm trying to read its content before modifying it then it is giving me error as ORA-06502: PL/SQL: numeric or value error: raw variable length too long:
    SELECT dbms_lob.substr(case_content, dbms_lob.instr( blob_column, utl_raw.cast_to_raw('Subject')),50)
    FROM my_table
    But below query gives me position properly:
    SELECT dbms_lob.instr( blob_column,utl_raw.cast_to_raw('Subject'))
    FROM my_table
    Thanks in advance.
    Regards,
    Chintan

    Firstly I would be wary of doing any string manipulation of binary data (.msg file). Secondly are you sure you have the parameters in dbms_lob.substr the correct way round: http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_lob.htm#i999349 You are getting the substring of case_content, starting with an offset of 50 and taking n bytes/chars where n is the postion of hte first occurence of "Subject" in case_content.
    Ben

Maybe you are looking for