DB2 DECIMAL FORMAT EXCEPTION (URGENT)

To undersdande my problem, please see the code below:
CODE A:
sql = "INSERT INTO DEC VALUES ('999999999999999.99',999999999999999.99')";
PreparedStatement stmt = con.getConnection().prepareStatement(sql);
stmt.executeUpdate();          
CODE B:
sql = "INSERT INTO DEC VALUES (?, ?)";
PreparedStatement stmt = con.getConnection().prepareStatement(sql);
stmt.setString(1, '999999999999999.99');
stmt.setDouble(2, 999999999999999.99);
stmt.executeUpdate();     
The Problem:
The table DEC tha I used has two columns, the first is a char(50) and the second is a Decimal(17,2) and its in DB2 running on AIX.
If I execute the firs statement, it execute very well. If I execute the second, the follow exception occurs:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is too large for its corresponding use. SQLSTATE=22003
If I reduce on algarism on number (14 digits and two decimals) the result is:
String Decimal
CODE A 99999999999999.99, 99999999999999.99
CODE B 99999999999999.99, 100000000000000.00
My question:
Is the code incompatible? Why?
Does anybody knows what is wrong?
I need help urgent!!!
Thanks in advance
Renato Melo

In code B when you are calling
In place of calling stmt.setDouble(2, 999999999999999.99);
call
stmt.setBigDecimal(2, new BigDecimal("999999999999999.99"));
Here is the explaination why you need to do that way
when you are calling
stmt.setDouble(2, 999999999999999.99);
DB2 converts your double number into BigDecimal which is like ( new Bigdecimal(999999999999999.99)
The problem with BigDecimal is as below
One might assume that new BigDecimal(.1) is exactly equal to .1, but it is actually equal to .1000000000000000055511151231257827021181583404541015625. This is so because .1 cannot be represented exactly as a double (or, for that matter, as a binary fraction of any finite length). Thus, the long value that is being passed in to the constructor is not exactly equal to .1, appearances nonwithstanding.
The (String) constructor, on the other hand, is perfectly predictable: new BigDecimal(".1") is exactly equal to .1, as one would expect. Therefore, it is generally recommended that the (String) constructor be used in preference to this one.

Similar Messages

  • Loading the data from a packed decimal format file using a sql*loader.

    Hi ,
    In one of the project i'm working here i have to load the data into oracle table from a file using a Sql*loader but the problem is the data file is in the packed decimal format so please let me know if there is any way to do this....I search a lot regarding this ..If anybody faced such type of problem ,then let me the steps to solve this.
    Thanks in advance ,
    Narasingarao.

    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;SY.

  • Key figure Date in Decimal format

    Hi all,
       I have a key figure 0CPR_ACFR_K  (Date) which is in Decimal format.
       Data in PSA for the particular field was like this '07102008'
       but after that it is changing to 7327.98  that is in decimal format.
       But i dont want this to happen ie. it should not get converted to Decimal or
       i want to convert the decimal value again to the equivalent date.
       pls help in this.

    Hi  jean liker,
    It will get converted due to its properties. If you want to use this particular object as keyfigure, you can create a variable with processing type replacement path and use. Its better to maintain as char.
    [Replacement Path: Replacement with a Characteristic Value|http://help.sap.com/saphelp_nw04/helpdata/en/03/6ba03cc24efd1de10000000a114084/frameset.htm]
    Hope it Helps
    Srini

  • Convert a String to Decimal Format in European format

    Hi Experts,
    I am having a string as a context type for a input field, where the user can enter the Price, I need to convert the same into European format "###.###,00", I am using this below code to convert the string to decimal format
    User will enter the input as 10 as it needs to be converted into 10,00. Also, 1000 which has to be converted as 1.000,00
    String Str1 = wdContext.currentvn_temptable.getVa_TempUnitPrice();
    Locale mylocale  = Locale.GERMAN;
    String pattern="###.###,00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(Str1);
    wdComponentAPI.getMessageManager().reportSuccess("Unit Price" + " " + pattern + " " + output);
    When I execute the above code, i am getting an error called "Malformed Pattern ###.###,00"
    Please let me know, how to convert a String to Quantity in European format
    Thanks & Regards,
    Palani

    Hello!
    Try to change your pattern to this one 
    Locale mylocale  = Locale.GERMAN;
    String pattern = "#,#00.00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(1111111.222);
    Pattern has an influence on number of digits between separators, but you have to use ',' for grouping and '.' for decimal. Character values for separators correspond to your Locale object.
    Thanks, Mikhail

  • Decimal format time value to convert into time (hr:min:sec)value in a graph

    I need to develop a graph in WAD, in BW7. In the graph the value must be showed as HR:MIN:SEC, which I cannot get it right.
    The keyfigure value  carries the duration(hr:min:sec) in decimal format.  In the query, I use this keyfigure for calculation. To get the time broadcasted for a week range. I get the total duration (say 507835.000). Now I need to convert this value back to hr:min:sec. I use the below formulas to get the hr, min, sec.
    D = 507835
    Val1 = D/3600
    Val2 = Frac(val1)
    Val3 = Val2 * 60
    Val4 = frac(Val3) * 60
    Hr = Val1 – Val2
    Min =  Val3 – frac(Val3)
    Sec =  Val4
    In another formula in the query I add Hr + Min/100 + Sec/10000 to get hr.minsec format.
    When I do an average on count of weeks,  this doesn’t round off correctly.
    I tried to also use the Data function TIME() which when the time is > 24 hrs changes the value.
    Lets say if it is 39:00:00, it shows value as 15:00:00 instead of keeping the value 39:00:00.
    When I used this value in the graph it did not show the HR:MIN:SEC values in the value axis instead  it showed 0.0, 0.1,….1.0. Bcoz of this the graph is blank.
    Can anybody help me to resolve this problem.
    Thanks alot
    Anima

    I checked SU01 and didn't see anything there to customize...
    In my workstation, control panel / regional and languages settings / tab regional Options / customize; my time format is HH:mm:ss; the HH has to be in capital letter to display the time in 24 hour...
    but this is strange anyway... are you reporting with web frontend or excel?

  • DBMS_XMLSave.insertXML Fails on decimal format

    DBMS_XMLSave.insertXML Fails on decimal format
    The following example fails when using collections of complex elements. The error is:
    java.lang.NumberFormatException: 1.0'
    Example is:
    create table test_parent(p_id NUMBER(18),
    test_col number(10))
    alter table test_parent add constraint pk1 primary key(p_id)
    create table test_child(t_id NUMBER(18),
    test_col number(10),
    p_id NUMBER(18))
    alter table test_child add constraint pk2 primary key(t_id)
    alter table test_child add constraint fk1 foreign key (p_id) references test_parent(p_id)
    insert into test_parent values(1,1)
    insert into test_child values(1,1,1)
    insert into test_child values(2,2,1)
    insert into test_child values(3,3,1)
    create type test_c AS OBJECT (t_id NUMBER(18),test_col NUMBER(10));
    CREATE OR REPLACE TYPE test_cs AS TABLE OF test_c
    CREATE OR REPLACE VIEW test_view(parent_id,parent_num,child)
    AS SELECT p.P_id,
    p.test_col,
    CAST(MULTISET(SELECT c.t_id,
    c.test_col
    FROM test_child c
    WHERE p.p_id = c.p_id) AS test_cs) AS child
    FROM test_parent P
    CREATE OR REPLACE TRIGGER test_trig INSTEAD OF INSERT ON test_view
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Trigger proccessing');
    END;
    SHOW ERRORS
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<ROWSET>
    <ROW>
    <PARENT_ID>2.0</PARENT_ID>
    <PARENT_NUM>2.0</PARENT_NUM>
    <CHILD>
    <T_ID>1.0</T_ID>
    <TEST_COL>1.0</TEST_COL>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;
    DECLARE
    insCtx DBMS_XMLSave.ctxType;
    rows number;
    xmlDoc CLOB := '<?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <PARENT_ID>1</PARENT_ID>
    <PARENT_NUM>1</PARENT_NUM>
    <CHILD>
    <TEST_C>
    <T_ID>1.0</T_ID>
    <TEST_COL>1</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>2</T_ID>
    <TEST_COL>2</TEST_COL>
    </TEST_C>
    <TEST_C>
    <T_ID>3</T_ID>
    <TEST_COL>3</TEST_COL>
    </TEST_C>
    </CHILD>
    </ROW>
    </ROWSET>';
    BEGIN
    insCtx := DBMS_XMLSave.newContext('TEST_VIEW');
    rows := DBMS_XMLSave.insertXML(insCtx,xmlDoc);
    DBMS_XMLSave.closeContext(insCtx);
    END;

    If you have access to ON, check out document 119140.1.
    Apparently it's a bug in the jdbc driver in pre-Oracle 8.1.7 databases...the workaround looks messy though.

  • Decimal Format and Scientific Notation

    I am trying to print numbers in scientific notation using the Decimal Format class. What follows is a simple test program I wrote to find the bug. So far, I have not found a solution.
    import java.text.*;
    public class formatted {
    public static void main (String Arguments[]) {
    DecimalFormat form = new DecimalFormat("0.###E0");
         double numb = 123456.789;
         System.out.println("Nuber is: " +
    form.format(numb));
    The output of this program is... Nuber is: 123456E
    The output is the same if numb is an int, float, or double. If I format the number as "#####.0" or "#####.00" the output is correct. I think that I am following the rules for formatting a number in scientific notation as the process is outlined in the documentation (provided below).
    ***** From Decimal Format under Scientific Notation ***
    Numbers in scientific notation are expressed as the product of a mantissa and a power of ten, for
    example, 1234 can be expressed as 1.234 x 10^3. The mantissa is often in the range 1.0 <= x < 10.0,
    but it need not be. DecimalFormat can be instructed to format and parse scientific notation only via a
    pattern; there is currently no factory method that creates a scientific notation format. In a pattern,
    the exponent character immediately followed by one or more digit characters indicates scientific
    notation. Example: "0.###E0" formats the number 1234 as "1.234E3".
    Anyone understand how the short program is incorrectly written?
    Marc

    The problem is
    format = "0.###E0"
    input number = 123456.789
    output = 123456E (not scientific notation!)
    This is not scientific notation at all. There is no decimal point given and no value in the exponent.
    I understand entirely that by adding more #'es will provide more precision. The bug I have is the output is not printed in the scientific format; other formats work.
    MArc

  • Decimal format to 2 decimal places ????

    Hello Everyone,
    I have created a web dynpro application which to display a report depending on the data given by the BAPI. But there is some issue with the numeric data returned by the BAPI.
    For ex - if the BAPI returns 5.00 the value is displayed in the report as 5.
    I want uniform decimal values till 2 decimal places. For example 5 shd come as 5.00, 2.1 shd come as 2.10 etc.
    I searched SDN abt this, and found many threads relating to this.
    I tried using decimal format, creating a simple dictinary type, but using all this what happens is the value basically changes to a string format, this implies that the value is displayed in the table as "left-aligned".
    Where- as we need the decimal numeric values to be right-aligned.
    Any thoughts how to achieve this.
    Please correct me if I have missed out on anything.
    Thanks,
    Samta

    Hi,
    From wat i understood.. u have a attribute coming from BAPI.. which you want to display with two decimal places,,
    In this case.. assuming it is coming with 2 decimal places from the backend..  create a value node.. inside the node which contains the output data. set its carinality to 1..1 .. create a value attribute of type big decimal in it.. or probably string.. if there is an issue in displaying BigDecimal directly..
    map this new attribute to the necessary column in the table..
    BigDecimal value = new BigDecimal("the actual value in string or long").setScale(2);
    assign this to the value attribute created..
    (If alignment is the problem.. set the column 's textview property halign to right.. and layout as block or paragraph.. )
    Regards
    Bharathwaj
    Message was edited by:
            Bharathwaj R

  • Convert a column in Numbers that is currently in HH:MM format to decimal format.

    I need to Convert a column in Numbers that is currently in HH:MM format to decimal format.  IE 6:30 to 6.5

    Rj,
    There are two possibilities here. Your HH:MM could be a Date/Time value or a Duration.
    Let's assume your data is in Column A.
    If it's a Date/Time value, do the conversion with the expression:
    =TIMEVALUE(A) * 24
    If it's a Duration value, do the conversion with the expression:
    =DUR2HOURS(A)
    In both cases, remember to Format the result to Number with at least one decimal place.
    Regareds,
    Jerry

  • Time format to Decimal format

    Hi all
    Does anyone know how to format time format to decimal number?
    Eg: '10:21' in HH24:MI to 10.21
    '21:09' to 21.09
    Thanks in Advance
    Prash

    Since you just want to replace the colon with a period in a string, just use the string replace function:
    select replace('10:21',':','.') from dual;However if you convert this to a number, then as Boneist said it's not really comparable to the time portion of a date as 21 minutes is not 21/100 of an hour but is rather .35 hours (21/60). You won't be able to use this decimalized format as a meaningful number, nor will you be able to do any sort of date based arithmatic on it.
    You may be better off converting your string to date, then into a number via some date math:
    with sample_data as (select to_date('11:21','HH24:MI') dt from dual)
    select dt, (dt - trunc(dt))*24 from sample_data;Edited by: Sentinel on Nov 10, 2008 9:40 AM

  • Property to set hex/binary/decimal format at run time?

    Hi, I'd like to allow my user to choose between hex/binary/decimal formats in his number input. I'm happy to do the radio button stuff and the code to "hear" what he wants, but I can't find a property of my variable which selects the format at run-time - there is of course the "Format & Precision..." which I can get at by right mouse click BEFORE running, so I know it's likely to be available at run-time. Any suggestions welcome. Thanks, Richard.

    It's not necessary to use property node because you can use the builtin
    property of the indicator.
    Click the rigth mouse button over the indicator and select show radix.
    On the left side of the indicator appear radix that you can push to choose
    between hex, binary, octal and decimal.
    Bye
    Golzio
    "R" ha scritto nel messaggio
    news:[email protected]..
    > Hi, I'd like to allow my user to choose between hex/binary/decimal
    > formats in his number input. I'm happy to do the radio button stuff
    > and the code to "hear" what he wants, but I can't find a property of
    > my variable which selects the format at run-time - there is of course
    > the "Format & Precision..." which I can get at by right mouse click
    > BEFORE run
    ning, so I know it's likely to be available at run-time. Any
    > suggestions welcome. Thanks, Richard.

  • Use of comma decimal format in % Breakdowns

    Hello,
    We have global users who would like to enter their decimal values for % Formulation and/or Ranges on the %Breakdowns in the comma decimal format (i.e. 9,99).  This does not seem possible regardless of free text language.  I just wanted to confirm that this was the case.
    Thanks,
    Drew

    Dear Kai,
    Thank you for your reply.
    I read the note and found that if I change my browser language to EN,
    everything works fine.
    However, if I change back my browser language to Chinese,
    the decimal seperator becomes comma.
    In the note 1064448, it said it's related to country settings.
    And the note gave a XML code to set the language to EN.
    But...if I put this code to my WAD XHTML,
    does that mean my chart's related settings, like axis label,
    would also change to English format?
    (Because when I change my browser language to EN, the chart's axis label and some other description also change to EN.)
    Is there any way that I can set the log on language Chinese should use decimal seperator "." instead of ","?

  • Currency decimal format

    Hi,
    I wanted to know if there is any table which stores the currency format for decimal places. for e.g some currencies use a period to indicate the decimal place while some use a comma.
    if the amount is 127.54
    in USD it will be 127.54
    in FRF it will be 127,54
    Is there any table which stores this information as to which currencies use comma and which use period.
    Thanks,
    Prasy

    I think the decimal format is controlled by the user setting not the currency being output. For example:
    REPORT ztest LINE-SIZE 80 MESSAGE-ID 00.
    DATA: amt TYPE bseg-dmbtr VALUE '123.45'.
    WRITE: /001 amt CURRENCY 'FRF'.
    gives output for me as:
    123.45
    Rob

  • How to stopping rounding  using decimal format

    my problem is as
    1. I am taking a double input in a jtextfield
    2. Now i am using decimal format to round it to 6 decimal places
    Now , how to make sure that decimal format while formatting do not round
    like If input is 1.2345678 i want to get 1.234567 not 1.234568

    That's not really an SCCSE.
    Anyhow, why not just use Double.parseDouble() if you don't want any rounding etc. Don't forget to catch the NumberFormatException:
    parseDouble
    public static double parseDouble(String s)
    throws NumberFormatException
    Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
    Parameters:
    s - the string to be parsed.
    Returns:
    the double value represented by the string argument.
    Throws:
    NumberFormatException - if the string does not contain a parsable double.
    Since:
    1.2
    See Also:
    valueOf(String)

  • Change decimal format to time format ie 1.5 to 1:30

    Hi I need to create a field such that when you enter a value in decimal format it gets converted to time format.
    Eg change 1.5 to 1.3 ..... Can any one help cheers.... any light on how to do this would be much appreciated.

    create table num_to_time (seq number, val number, dtvl date);
    insert into num_to_time
    select 1 seq, 1.5 val, null dtvl from dual
    union all
    select 2, 2.25, null from dual;
    commit;
    create or replace procedure p_numtotime is
    v_seq num_to_time.seq%type;
    v_val num_to_time.val%type;
    v_date num_to_time.dtvl%type;
    cursor c1 is select * from num_to_time;
    begin
    open c1;
    loop
    fetch c1 into v_seq,v_val,v_date;
    exit when c1%notfound;
    update num_to_time set
    dtvl = to_date(to_char(trunc(sysdate)) ||
    ' 0'||trunc(v_val)||':'||to_char(mod(v_val,trunc(v_val))*60)||':00',
    'dd/mm/yyyy hh24:mi:ss')
    where seq = v_seq;
    end loop;
    commit;
    close c1;
    end;
    exec p_numtotime;
    drop table num_to_time;
    drop procedure p_numtotime;

Maybe you are looking for

  • .svg italics problem

    Hello I'm having a problem with italics font in .svg files. Illustrator shows the font correctly (times new roman) but if I open it in a browser (firefox) there are no italics. Where did I go wrong? I made some svg files last year, and didn't have th

  • Drop shadow on font in pie charts

    I cannot figure out how to remove the drop shadow on the font in pie charts. It looks ok if I have the font remain in white, but if I change the font to black, it looks really fuzzy. No, the shadow box is not checked. Yes, I have checked out the text

  • ABAP + JAVA HA Installtion on Windows 2003

    Hello Everyone, We are in process of installation of ABAP + JAVA in HIgh Availability on windows server 2003 , oracle database. Our plan is to install ASCS, SCS, DB , CI on node A & DI on Node B. In Installation guide its given that " Central instanc

  • Migration from 8i to 9i/10g

    Hi , I am current using Oracle 8i, is the migration to 9iR2 or 10g free? Do i need to pay to upgrade to the newer database? Am currently using 817 Enterprise Edition. Thanks in advance.

  • Every time I click on the browser I get a Firefox is configured to use a proxy server that is refusing connections.

    I can't connect to the firefox browser. Every time that I click on the browser I get a " The proxy server is refusing connections. Firefox is configured to use a proxy server that is refusing connections. " I've never had this problem before. I'm now