Rounding UP numbers in pl\sql

Hi is there a way to round up numbers in pl\sql?

Maybe you are looking for CEIL.
with testdata as (select level/3-2 num from dual connect by level<=15)
select num, round(num), ceil(num)
from testdata;
NUM    ROUND   CEIL
-1,67     -2     -1
-1,33     -1     -1
-1     -1     -1
-0,67     -1     0
-0,33     0     0
0     0     0
0,33     0     1
0,67     1     1
1     1     1
1,33     1     2
1,67     2     2
2     2     2
2,33     2     3
2,67     3     3
3     3     3

Similar Messages

  • Displaying line numbers in oracle Sql developer

    hi guys, can someone tell me how to display line numbers in oracle sql developer Version 2.1.1.64?.

    I absolutely didn't know where it was, so I had to look for it, and it appears easy to find.
    Hit Tools
    Hit Preferences
    Expand Code Editor
    Navigate to line gutter
    Now click 'Show line numbers'
    And, oh yes, there is a separate sql developer forum. Please keep sql developer issues in that forum.
    Sybrand Bakker
    Senior Oracle DBA

  • I get a problem on Report doing in migration ,Round Changes to Trunc in sql

    Hi
    Actually problem is in migration process, from siebel 7.8 get migrated to OBIEE 10.1.3.4.0
    problem
    we have 10 reports that show in sql as ROUND function in seibel
    that same report run in obiee it sql shows that in TRUNC in obiee
    i need the ROUND function in obiee
    my database is oracle10g it not change in migration
    And I cheak in DB features Also there is mark on Round_support and Trunc_support
    Please Help me to sort out this issue
    Advance Thanks

    Set the default startup disk
    Resolve startup issues and perform disk maintenance with Disk Utility and fsck
    How to fix slow shutdown and startup times. | MacTip.net

  • ETEXT output truncating/rounding large numbers

    I have an eTEXT template that includes the definition:
    <FORMAT>     <DATA>
    NUMBER BankAccount/BankAccountNumber
    When a large number is encountered the output appears truncated/rounded. For example; the account number 444470301880513641 is output as 444470301880513660.
    Data:
    <BankAccountNumber>444470301880513641</BankAccountNumber>
    Output:
    ...#444470301880513660#....
    Other than convert the FORMAT to an Alpha are there any known tips or tricks to correct this scenario?
    Regards
    Edited by: bdansie on 10-Jan-2012 17:44

    Hi Tom, Thanks for the reply. I am reading a hex value in from a serial port. the number is large and when i format it as hex on one chan it is off by a small amount. there is some rounding in the LSD. i then take another reading later and calculate the delta. since i dont have the right values to begin with my difference calculation is wrong. when i read as bytes through 8 channels, i can see the ascii for each digit and that they are correctly displayed. using a formula module i can convert from ascii to decimal so that i get the decimal equivalent of the hex character then in the next formula i do the math to find the value of each hex digit in place it holds. then using a sum arithmetic module i get the final value of the large number coming in. it is correct all the way upto the aritmetic sum. i tried cutting the large hex number into two parts and then adding up the weighted parts and still have the wrong ans in the display module. i also tried dividing the halves by 1000 prior to adding them so that i was working with smaller numbers in the summation but that didnt help.
    so i did the math directly in the extended portion of the variables. the numbers add up properly there but when i try to bring the correct sum back into the work sheet to display it, it is wrong again. it seems that a value around 04000000 hex is the limit. below that i get the right value displayed that was calculated in the variable field, above it there is some degree of variation. I can set the limit of cycles to a value below where the addition becomes problematic or i can export the hex to a spreadsheet, do the math there and then bring it back in but i will still have the same issue displaying the answer.
    the limitation doesnt seem to be in DASYLab in general but in the Read, Formula, Constant Generator modules that read the variable back into the worksheet. it is displayed properly in the contents window

  • Pages rounding up numbers in a .doc file to 2 decimal places

    Hello, I have a problem, with Pages (3.4) on OS 10.7.5...
    When I go to open a .Doc file, Pages seems to round up some numbers to 2 decimal places. I did find another thread which dealt with this problem inside of Tables, but I am not using tables in this document.... another problem is that the new rounded up number is not editable in Pages once the document is open. e.g.
    In word/open office I see the figure (which is in fact a series of dates - i did not write this document btw)
         12.12.24.1.13
    in Pages is only see
         .13
    and this .13 is totaly un-editable and unselectable.
    Can you help ?

    Got it!
    I tried opening it in TextEdit but the funky dates were omitted from the page. Then I opened it in LibreOffice and it looked OK. The problematic dates seemed created by a special Word function. The behaving dates were manually written.
    I selected all content of the document in LibreOffice and pasted into a Pages document and all dates came out as they should.

  • Rounding decimal numbers in the planning book

    Hi,
    Is there any way to round up the decimal numbers shown in the forecast/inventory/DRP planning book of SPP ?
    Thanks and Regards
    Mitesh

    Hi Mitesh,
    Please go to SPRO:
    APO -> Supply Chain Planning -> SPP -> Settings for user interfaces -> Assign Key Figures
    Go to "Semantic Maintenance"
    Set "Decimal Places" Column to Zero for all key figures.
    Regards,
    Aapka Mukundan

  • How can I change the format of numbers in Oracle SQL Developer 1.0 ?

    The value 1.4345 from a table is represented in Oracle SQL Developer 1.0 like 1.5
    How can I change this to see all the digits ?
    Thanks

    Where did you see that, in the SQL Worksheet or viewing the data Connections ->.. tables ->.. tree?
    What datatype, precision and column name you have?
    I use version 1.0.0.15.57 and seems to be working allright.
    - Babu Rangasamy

  • Rounding up numbers

    Hi,
    I would like to know how to round up number in jsp whether it is below 0.5 or above 0.5... my sample code:
    double totalquantity=0;
    int totalratio = 0;
    long q = 0;
    ratio = rs.getString("ratio");
    q = totalquantity/totalratio * Integer.parseInt(ratio);
    thank you

    you are getting the double through the expression mentioned
    q = totalquantity/totalratio * Integer.parseInt(ratio);
    and assigning that to long, without casting.
    Hence the problem-Loss Of Precision.Make the q as double,use Math.round() on that depending on u r requirement.

  • Numbering system in Sql Server

    hi
    i am using sql server 2008 & vs 2008 C#
    i have table
    [tbl_CashCounter](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [BillNo] [nvarchar](50) NULL,
    [BillDate] [datetime] NULL
    i want BillNo  A0001,A0002,..........A9999.
    if it reached A9999 it should new series like  B0001,B0002,..........B9999.
    then C,D,.........Z
    i am looking sql function or store procedure which will return max  Series No.
    i want use like this
    txtBillNo.text =  getMaxNo();
    Thanks Best Regard Naweez

    As per your scenario, below the code is working fine as well as good performance. Code was tested in SQL SERVER 2008 R2.
    CREATE FUNCTION getMaxNo()
    RETURNS VARCHAR(5)
    AS
    BEGIN
    DECLARE @Max_no varchar(5), @numeric int
    SELECT @Max_no= ISNULL(MAX(BillNo),'A0001') FROM [tbl_CashCounter]
    SET @numeric=CAST(RIGHT(@Max_no,4) AS INT)+1
    SELECT @Max_no=(CASE WHEN RIGHT(@Max_no,4)=9999 THEN char(ASCII(left(@Max_no,1))+1)+'0001'
    ELSE left(@Max_no,1) END)
    +''+
    ISNULL(CASE WHEN len(@numeric)=1 THEN '000'+CAST(CAST(RIGHT(@Max_no,4) AS INT)+1 AS VARCHAR(4))
    WHEN len(@numeric)=2 THEN '00'+CAST(CAST(RIGHT(@Max_no,4) AS INT)+1 AS VARCHAR(4))
    WHEN len(@numeric)=3 THEN '0'+CAST(CAST(RIGHT(@Max_no,4) AS INT)+1 AS VARCHAR(4))
    WHEN len(@numeric)=4 THEN ''+CAST(CAST(RIGHT(@Max_no,4) AS INT)+1 AS VARCHAR(4))
    END,'')
    RETURN @Max_no
    END
    GO
    Regards,
    RAMBHARATH
    thanks its working fine i just modified
    alter FUNCTION getMaxNo()
    RETURNS VARCHAR(5)
    AS
    BEGIN
    DECLARE @Max_no varchar(5), @numeric int
    SELECT @Max_no= ISNULL(MAX(BillNo),'A0001') FROM [tbl_CashCounter]
    SET @numeric=CAST(RIGHT(@Max_no,4) AS INT)+1
    SELECT @Max_no=
    (CASE WHEN RIGHT(@Max_no,4)=9999 THEN char(ASCII(left(@Max_no,1))+1)+'0001'
    ELSE left(@Max_no,1)
    END)
    +''+ ISNULL( replicate('0', 4 - len(@numeric)) + CAST(CAST(RIGHT(@Max_no,4) AS INT)+1 AS VARCHAR(4)),'')
    RETURN @Max_no
    END
    GO
    Thanks Best Regard Naweez

  • Rounding of Numbers

    Hi, can somebody tell me why the following generates this output it looks like ROUND_HALF_EVEN but should round up always.
    import java.math.BigDecimal;
    public class TestDecimal {
         public static void main(String[] args) {
              System.out.println(new BigDecimal(1.45).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue());
              System.out.println(new BigDecimal(1.55).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue());
              System.out.println(new BigDecimal(1.65).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue());
    }1.4 => Should be 1.5
    1.6 => Should be 1.6
    1.6 => should be 1.7
    Am I completely mistaken? This is java-1.5. How can I achive what I want rounding up starting with >= 0.5 like we learned in school and is documented in javadoc of ROUND_HALF_UP.

    System.out.println("1.44 => 1.4 => " + new BigDecimal(1.44).setScale(1,RoundingMode.HALF_UP).doubleValue());
    System.out.println("1.45 => 1.5 => " + new BigDecimal(1.45).setScale(1,RoundingMode.HALF_UP).doubleValue());
    System.out.println("1.54 => 1.5 => " + new BigDecimal(1.54).setScale(1,RoundingMode.HALF_UP).doubleValue());
    System.out.println("1.55 => 1.6 => " + new BigDecimal(1.55).setScale(1,RoundingMode.HALF_UP).doubleValue());
    System.out.println("1.64 => 1.6 => " + new BigDecimal(1.64).setScale(1,RoundingMode.HALF_UP).doubleValue());
    System.out.println("1.65 => 1.7 => " + new BigDecimal(1.65).setScale(1,RoundingMode.HALF_UP).doubleValue());Produces:
    1.44 => 1.4 => 1.4
    1.45 => 1.5 => 1.4
    1.54 => 1.5 => 1.5
    1.55 => 1.6 => 1.6
    1.64 => 1.6 => 1.6
    1.65 => 1.7 => 1.6
    The same result is with:
    MathContext context = new MathContext(2,RoundingMode.HALF_UP);
    new BigDecimal(1.44).round(context).doubleValue();

  • Output of numbers only through sql

    Suppose i have a column value for lot_no=10 like
    serial_no lot_no
    1 10
    2 10
    3 10
    4 10
    6 10
    7 10
    9 10
    11 10
    12 10
    13 10
    I want output like
    serial_no lot_no
    1-4 10
    6-7 10
    9 10
    11-13 10
    it is possible to solve through pl/sql.
    can we do it with out using pl/sql ????

    You don't need PL/SQL:
    SQL> column serial_no format a10
    SQL> create table mytable (serial_no,lot_no)
      2  as
      3  select 1, 10 from dual union all
      4  select 2, 10 from dual union all
      5  select 3, 10 from dual union all
      6  select 4, 10 from dual union all
      7  select 6, 10 from dual union all
      8  select 7, 10 from dual union all
      9  select 9, 10 from dual union all
    10  select 11, 10 from dual union all
    11  select 12, 10 from dual union all
    12  select 13, 10 from dual
    13  /
    Table created.
    SQL> select to_char(min(serial_no)) ||
      2         case
      3         when min(serial_no) != max(serial_no)
      4         then '-' || to_char(max(serial_no))
      5         end serial_no
      6       , lot_no
      7    from ( select serial_no
      8                , lot_no
      9                , serial_no - row_number() over (partition by lot_no order by serial_no) grp
    10             from mytable
    11            where lot_no = 10
    12         )
    13   group by grp
    14       , lot_no
    15   order by serial_no
    16  /
    SERIAL_NO      LOT_NO
    1-4                10
    11-13              10
    6-7                10
    9                  10
    4 rows selected.Regards,
    Rob.

  • SQL Loader and Floating Point Numbers

    Hi
    I have a problem loading floating point numbers using SQL Loader. If the number has more than 8 significant digits SQL Loader rounds the number i.e. 1100000.69 becomes 1100000.7. The CTL file looks as follows
    LOAD DATA
    INFILE '../data/test.csv' "str X'0A'"
    BADFILE '../bad/test.bad'
    APPEND
    INTO TABLE test
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
    Amount CHAR
    and the data file as follows
    "100.15 "
    "100100.57 "
    "1100000.69 "
    "-2000000.33"
    "-100000.43 "
    the table defined as follows
    CREATE TABLE test
    Amount number(15,4)
    ) TABLESPACE NNUT050M1;
    after loading a select returns the following
    100.15
    100100.57
    1100000.7
    -2000000
    -100000.4
    Thanks in advance
    Russell

    Actually if you format the field to display as (say) 999,999,999.99, you will see the correct numbers loaded via SQL Loader.
    null

  • Formating numbers in a form after retrieving from an SQL database

    Hello everyone,
    I am using php to populate a form using numbers taken from an sql database.  I am having a hard time showing decimal places in those numbers.  The code I am using in the value section of the form is:
    value="<?php if (isset($_POST['unit_price_1'])) {
         echo htmlentities( $_POST['unit_price_1'], ENT_COMPAT, 'UTF-8');
         } else {
              echo htmlentities($row_getInvoice['unit_price_1'], ENT_COMPAT, 'UTF-8');
         } ?>" />
    This code rounds all numbers up and eliminates decimal places.  I am trying to show dollars and cents.
    How do I alter the code to accomplish what I want.
    Jeff

    Not sure what might come in your way here, so I just made the following simple test by using a static value rather than one which gets derived from a recordset (the source shouldn´t matter), and this works well for me without seeing the value altered in any way:
    <?php
    $value = "10.22";
    ?>
    <input type="text" name="whatever" value="<?php echo htmlentities($value, ENT_COMPAT, 'UTF-8'); ?>" />
    However,. for displaying numeric values you really don´t need to use  htmlentities/ENT_COMPAT etc etc -- that´s something you´d rather use for displaying textual contents containg special characters like umlauts and such.
    If all you need is to add some degree of protection by escaping special HTML characters (<, >, &, etc.), the function htmlspecialchars() will only be escaping just these characters and leave the rest "as is", whereas htmlentities() is notably more rigi, because this function will convert all applicable characters to HTML entities -- but again: at this point you´re just *displaying* some numeric value, that is, such security measures are pretty much pointless in this scenario, because there´s nothing to protect from ;-)
    Please test what happens when doing away with the htmlentities - thing.
    Cheers,
    Günter

  • Adobe Reader XI - How do i stop numbers being rounded up on forms

    Hi,
    I am using the Adobe Reader XI, with regards to filing in figures on forms that I use. The form keeps on rounding up numbers. For example if I type in 2.5 and go to the next box on the form, the figure will immediately change to 3. It is extremely frustrating and in my line of work the figures have to be exact. Please can anyone help and advise if there is anything I can do or settings that I can change to be able to keep numbers on the form with decimal points showing without them being rounded up.
    Thanks

    To emphasise: this happens only if the designer of the form decides to not allow any decimal places.

  • Number gets rounded while inserting

    Hi,
    Help required
    query is as below :
    desc test_load
    Name Null? Type
    B VARCHAR2(10)
    select b,substr(b,1,length(b)-2)||'.'||substr(b,-2,2) amt from test_load;
    B AMT
    3232922618 32329226.18
    desc sql_amt
    Name Null? Type
    A NUMBER
    insert into sql_amt
    select substr(b,1,length(b)-2)||'.'||substr(b,-2,2) amt from test_load;
    select * from sql_amt;
    A
    32329226.2
    the above values rounded 32329226.2 it should be 32329226.18
    Pls let me know the Solution
    Thanks & Regards
    Vishal

    As Citrus pointed out, it's merely to do with how the data is displayed in the tool which retrieves it, not how the data is actually stored on the database.
    If your retrieval environment (SQL*Plus, Toad or whatever) is set to display numbers with a single decimal place then they will automatically round your numbers as they are retrieved. This doesn't mean that the data is stored wrongly on the database, just that you haven't specified the correct display format for your requirements in your tool.
    ;)

Maybe you are looking for