Number of digits of a Long value

Hi there,
I want to calculate the number of digits of Long value. My first idea was to use
Long l = 1010101101010101010L;
int lLength = l.toString().length();is there a better way to do this?
regards,
Olek

log10() gives a NaN for negative values. Via a char array the digits can easily be counted.
public class NumberOfDigits {
    public static void main(String[] args) {
     numberOfDigits(-10101010101l);
    public static void numberOfDigits(Long l) {
     System.out.println();
     System.out.println("Value: " + l);
     System.out.println("Via String: " + l.toString().length());
     System.out.println("Via log 10: " + (int) Math.ceil(Math.log10(l)));
     char[] chars = l.toString().toCharArray();
     int count = 0;
     for (char c : chars) {
         if (Character.isDigit(c)) {
          count++;
     System.out.println("Via chars: " + count);
     if (l < 0) {
         numberOfDigits(Math.abs(l));
}Piet

Similar Messages

  • Number of Digits.

    Hi,
    We have problem with our amount fields. If we enter more than a
    million then the following error occurs. We are using Double and
    double data types to calculate.
    java.lang.NumberFormatException: 87654321E8 at
    java.lang.Long.parseLong(Long.java:324) at java.math.BigInteger.
    (BigInteger.java:251) at java.math.BigInteger.(BigInteger.java:280)
    at java.math.BigDecimal.(BigDecimal.java:111) at
    com.iplanet.jato.util.TypeConverter$BigDecimalTypeConversion.convertVa
    lue(TypeConverter.java:745) at
    com.iplanet.jato.util.TypeConverter.asType(TypeConverter.java:270) at
    com.iplanet.jato.model.sql.ResultSetModelBase.hasValue
    (ResultSetModelBase.java:489) at
    com.iplanet.jato.model.sql.QueryModelBase.constructInsertSQL
    (QueryModelBase.java:575) at
    com.iplanet.jato.model.sql.QueryModelBase.getInsertSQL
    (QueryModelBase.java:239) at
    com.iplanet.jato.model.sql.QueryModelBase.getSQL
    (QueryModelBase.java:140) at
    com.iplanet.jato.model.sql.QueryModelBase.executeInsert
    (QueryModelBase.java:1859) at
    com.cbre.ras.voyager4.view.pgVoucherSalesLeaseViewBean.handleBtnAddReq
    uest(pgVoucherSalesLeaseViewBean.java:821) at
    java.lang.reflect.Method.invoke(Native Method) at
    com.iplanet.jato.view.RequestHandlingViewBase.handleRequest
    (RequestHandlingViewBase.java:341) at
    com.iplanet.jato.view.ViewBeanBase.invokeRequestHandlerInternal
    (ViewBeanBase.java:481) at
    com.iplanet.jato.view.ViewBeanBase.invokeRequestHandler
    (ViewBeanBase.java:431) at
    com.iplanet.jato.ApplicationServletBase.dispatchRequest
    (ApplicationServletBase.java:646) at
    com.iplanet.jato.ApplicationServletBase.processRequest
    (ApplicationServletBase.java:432) at
    com.iplanet.jato.ApplicationServletBase.doPost
    (ApplicationServletBase.java:297) at
    com.iplanet.jatox.ServletBase.doPost(ServletBase.java:129) at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:772) at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:865) at
    com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source) at
    com.netscape.server.servlet.servletrunner.ServletRunner.execute
    (Unknown Source) at com.kivasoft.applogic.AppLogic.execute(Unknown
    Source) at com.kivasoft.applogic.AppLogic.execute(Unknown Source) at
    com.kivasoft.thread.ThreadBasic.run(Native Method) at
    java.lang.Thread.run(Thread.java:479)
    everything works fine if the amount is 7 digits.
    Many of you might have come across this. Please let me know how to
    fix this.
    Thanks
    Mohan

    since this is happening during the preparation of an insert statement, it
    looks like the framework is trying to "coerce" your data field value into a
    BigDecimal, which in turn is calling BigInteger.
    Check the "column type" as specified in the data field descriptor? Is it
    what it should be from an JDBC perspective?
    Maybe you can forward the ModelImpl source file to us so we can be confer
    more specifically.
    send to michael.frisino@s...
    ----- Original Message -----
    From: <MShanmugam@c...>
    Sent: Wednesday, August 15, 2001 11:48 AM
    Subject: [iPlanet-JATO] Number of Digits.
    Hi,
    We have problem with our amount fields. If we enter more than a
    million then the following error occurs. We are using Double and
    double data types to calculate.
    java.lang.NumberFormatException: 87654321E8 at
    java.lang.Long.parseLong(Long.java:324) at java.math.BigInteger.
    (BigInteger.java:251) at java.math.BigInteger.(BigInteger.java:280)
    at java.math.BigDecimal.(BigDecimal.java:111) at
    com.iplanet.jato.util.TypeConverter$BigDecimalTypeConversion.convertVa
    lue(TypeConverter.java:745) at
    com.iplanet.jato.util.TypeConverter.asType(TypeConverter.java:270) at
    com.iplanet.jato.model.sql.ResultSetModelBase.hasValue
    (ResultSetModelBase.java:489) at
    com.iplanet.jato.model.sql.QueryModelBase.constructInsertSQL
    (QueryModelBase.java:575) at
    com.iplanet.jato.model.sql.QueryModelBase.getInsertSQL
    (QueryModelBase.java:239) at
    com.iplanet.jato.model.sql.QueryModelBase.getSQL
    (QueryModelBase.java:140) at
    com.iplanet.jato.model.sql.QueryModelBase.executeInsert
    (QueryModelBase.java:1859) at
    com.cbre.ras.voyager4.view.pgVoucherSalesLeaseViewBean.handleBtnAddReq
    uest(pgVoucherSalesLeaseViewBean.java:821) at
    java.lang.reflect.Method.invoke(Native Method) at
    com.iplanet.jato.view.RequestHandlingViewBase.handleRequest
    (RequestHandlingViewBase.java:341) at
    com.iplanet.jato.view.ViewBeanBase.invokeRequestHandlerInternal
    (ViewBeanBase.java:481) at
    com.iplanet.jato.view.ViewBeanBase.invokeRequestHandler
    (ViewBeanBase.java:431) at
    com.iplanet.jato.ApplicationServletBase.dispatchRequest
    (ApplicationServletBase.java:646) at
    com.iplanet.jato.ApplicationServletBase.processRequest
    (ApplicationServletBase.java:432) at
    com.iplanet.jato.ApplicationServletBase.doPost
    (ApplicationServletBase.java:297) at
    com.iplanet.jatox.ServletBase.doPost(ServletBase.java:129) at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:772) at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:865) at
    com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown
    Source) at
    com.netscape.server.servlet.servletrunner.ServletRunner.execute
    (Unknown Source) at com.kivasoft.applogic.AppLogic.execute(Unknown
    Source) at com.kivasoft.applogic.AppLogic.execute(Unknown Source) at
    com.kivasoft.thread.ThreadBasic.run(Native Method) at
    java.lang.Thread.run(Thread.java:479)
    everything works fine if the amount is 7 digits.
    Many of you might have come across this. Please let me know how to
    fix this.
    Thanks
    Mohan
    [email protected]

  • How to find the number of decimals in a given value

    Hi all,
    Can u please help me in solving the problem,
    i have a value called 5987.45
    and decimal places are 45 that is 2 numbers
    2) 765.987
    number of digits in decimals are 3.
    3) 67543.1
    number of digits in decimals are 1.
    for this i need a coding
    thanks.

    Hi,
    While printing your text element give as;
    &wa_tab-dec_value(.2C)&
    This will always print everything with 2 decimals.
    Regards
    Karthik D

  • How to get number of digits in given amount

    Hi Experts,
    How to get number of digits in given amount.
    Regards
    Mohit

    Check this :
    data: v_data1 type p decimals 3 value '12.860',
          v_char1 type char20,
          v_char2 type char20,
          v_char3 type char20,
          len type i.
    write v_data1 to v_char1.
    split v_char1 at '.' into v_char2 v_char3.
    len = strlen( v_char3 ).
    write:/ v_char2,
          / v_char3, " this holds the digit value
          / len.     " number digits

  • Dont allow user to enter more than specified number of digits/chars?

    Hello
    First case: I have placed a TEXT field on the form. Now i want to put the below validation,
    1) User has to enter only numbers (no decimals)
    2) Only 10 digits
    If not i need to
    1) Alert app.alert
    2) Make the field either CLEARIng or considering & resetting only the first 10 digits (if user entered more than 10 digits)
    2nd case: Same as above, a TEXT field, but, the data is with a DECIMAL notation, the allowed lenghts are as
    2 digits as prefix to decimal
    2 digits as suffix to decimal position
    example, 35.88
    Pls. let me knw the Java Script for these 2 cases or do you suggest me PATTERN validation if so, can i CLEAR or reset  and if so, pls. let me know under which TAB(Display / Edit / Data) i need to put the PATTERN validation?

    Firstly if you are only allowing numbers then the field should be a numeric field not a text field. You can use patterns to allow only whole numbers or to have 2 digits on either side of the decimal.
    In regards to the number of digits you can use the len function to determine the length of the data and if it is too long give a message or clear it.

  • Can't set long value when I type the value in

    I don't work with long values much so I don't know if I'm missing something but I'm working on a Java program that needs to get the last modified dates from files and see if they've been updated since the last run. Well the date it returns is long. I set a long variable and when I tried to type in the value of a file I get an integer number too large error. This is a direct paste of the last modified date on one of the files. However, if I tell the variable to equal the files date it works fine. What am I missing?
            long oldTime = 1169806999093;
            File tempFile = new File("C:\\cygwin");
            oldTime = tempFile.lastModified();

    You must tell the compiler that the thing on the right hand side is a long literal rather than an int literal:
    long oldTime = 1169806999093LL; // notice the L at the end

  • Validate that user should not enter more than specified number of digits/chars?

    Hello
    First case: I have placed a TEXT field on the form. Now i want to put the below validation,
    1) User has to enter only numbers (no decimals)
    2) Only 10 digits
    If not i need to
    1) Alert app.alert
    2) Make the field either CLEARIng or considering & resetting only the first 10 digits (if user entered more than 10 digits)
    2nd case: Same as above, a TEXT field, but, the data is with a DECIMAL notation, the allowed lenghts are as
    2 digits as prefix to decimal
    2 digits as suffix to decimal position
    example, 35.88
    Pls. let me knw the Java Script for these 2 cases or do you suggest me PATTERN validation if so, can i CLEAR or reset  and if so, pls. let me know under which TAB(Display / Edit / Data) i need to put the PATTERN validation?

    Firstly if you are only allowing numbers then the field should be a numeric field not a text field. You can use patterns to allow only whole numbers or to have 2 digits on either side of the decimal.
    In regards to the number of digits you can use the len function to determine the length of the data and if it is too long give a message or clear it.

  • Largest number of digits for NUMBER datatype?

    What is the largest length of a NUMBER that Oracle will "support"?
    The documentation says the following:
         Datatype Limits indicates:
             "Can be represented to full 38-digit precision"
         NUMBER Data Types indicates:
              "Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point."
    I realize if I define a column as simply NUMBER, I can insert numbers with a size up to 126 digits.  However, Oracle seems to only maintain the first 40 digits IN MOST cases.  The most number of digits it seems to allow is 40 before it starts to replace with 0's.
    With numbers that have more than 40 digits, Oracle will sometimes replace any numbers after the 38th digit with a 0 and other times will replace with 0 after the 39th or 40th digit.
    Therefore, what is the most number of digits we can have confidence in Oracle storing safely?
    This was the code I used for testing this process.
    create table max_num (num number);
    declare
      l_x number;
    begin
      for x in 1..200
      loop
        l_x := x;
        insert into max_num values (rpad(1, x, 1));
      end loop;
      exception
      when others then
        dbms_output.put_line('STOP: '||l_x);
        dbms_output.put_line(sqlerrm);
    end;
    select num, length(replace(num, 0)) from max_num;

    Hi,
    user109389 wrote:
    What is the largest length of a NUMBER that Oracle will "support"?
    The documentation says the following:
         Datatype Limits indicates:
             "Can be represented to full 38-digit precision"
         NUMBER Data Types indicates:
              "Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point."
    I realize if I define a column as simply NUMBER, I can insert numbers with a size up to 126 digits.  However, Oracle seems to only maintain the first 40 digits IN MOST cases.  The most number of digits it seems to allow is 40 before it starts to replace with 0's.
    With numbers that have more than 40 digits, Oracle will sometimes replace any numbers after the 38th digit with a 0 and other times will replace with 0 after the 39th or 40th digit.
    Therefore, what is the most number of digits we can have confidence in Oracle storing safely?...
    If the documentation says 38, then I'll say 38, too.
    If you put in a number greater than or equal to 1E39, then Oracle may round it to 38 significant digits; that is, the last digits you entered may get turned to 0's, or rounded up.

  • ORA-01461: can bind a LONG value only for insert into a LONG colu

    Hello - I have a variable defined in a package as VARCHAR2(32720). This is not a table column. I am building a string inside the vairable, loading in invoice data in sections one at a time. It seems that once I get a larger number of invoices (say 100+) to load in, I get the "ORA-01461: can bind a LONG value only for insert into a LONG column" error. I am not trying to insert into a table column; just stringing together data in this large variable.
    Why would I be getting this error ? And is there a workaround ? The variable is read back out iin 80 byte strings which are then loaded to a table column that is varchar2(80).
    Thanks !!
    Jim Ernst
    Invacare Corporation

    Here is the definition of the field:
    l_EDI820_Data VARCHAR2(32720);
    And here is the loop used to populate the field. As i mentioned, it seems that once the process gets over 100 invoices coming in that the field hits the error; seems as if we are hitting say 4000 characters or near it at that point...
    FOR r_INVOICE_DETAIL IN cr_INVOICE_DETAILS LOOP
    l_EDI820_Data := l_EDI820_Data
    ||l_RMR_Statement
    ||r_INVOICE_DETAIL.INVOICE_NUM
    ||'*PI*'
    ||LTRIM(TO_CHAR(NVL(r_INVOICE_DETAIL.PAYMENT_AMOUNT,0))) -- Net Amount to be applied
    ||'*'
    ||LTRIM(TO_CHAR(r_INVOICE_DETAIL.INVOICE_AMOUNT,'999999.99')) -- Gross Amount
    ||l_Delimiter;
    l_TOTAL_SEGMENTS := l_TOTAL_SEGMENTS + 1;
    END LOOP; -- r_INVOICE_DETAIL
    There are some other statements that are adding additional data onto l_EDI820_Data ; this one is the loop that is basedon the invoices coming in.
    This code writes it to the table (field EDI820_DATA in the table is VARCHAR2(94)):
    l_EDI820_String_Length := LENGTH(RTRIM(l_EDI820_Data));
    l_EDI820_SUBSTR_START := 1;
    l_RECORD_SEQ_NO := 1;
    WHILE SUBSTR(l_EDI820_Data, l_EDI820_SUBSTR_START, 80) <> ' ' LOOP
    INSERT INTO XXAP_NACHA_EDI820_GTEMP_TBL
    SELECTED_CHECK_ID
    ,EDI820_SEQ
    ,EDI820_DATA
    VALUES (
    r_CHECK_IDS.SELECTED_CHECK_ID
    ,l_RECORD_SEQ_NO
    ,'705'||SUBSTR(l_EDI820_Data, l_EDI820_SUBSTR_START, 80)
    -- * Increment starting point for substring and also record sequence number
    l_EDI820_SUBSTR_START := l_EDI820_SUBSTR_START + 80;
    l_RECORD_SEQ_NO := l_RECORD_SEQ_NO + 1;
    END LOOP; -- WHILE Loop

  • ORA-01461: can bind a LONG value only for insert into a LONG Classic Report

    I am trying to create a report but get a ORA-01461: can bind a LONG value only for insert into a LONG column error. I am a fairley new to Apex and my SQL skills are far from expert level. I have 3 groups we will call 'A' 'B' 'C'. 'A' is the best group 'B' is the next best and 'C' is the lowest group. Let say there are 5 people they all want to be in group A but where they are placed is based on their audition score and the users selection.
    Joe score is 50
    Beth 40
    John 30
    Ken 20
    Sally 10
    The user selects that he wants 2 people in group 'A' and 1 in group 'B' and 2 in group C. The SQL needs to rank Joe and Beth in Group A. John in group 'B' and Ken and Sally in group 'C'. The user does this type of selection for about 15 different instrument groups to make up group (band) for 'A', 'B', and 'C'.
    Here is what I have come up with that gives me the error mention above when creating a report but works in SQL developer. There is probably a far better way to write this than what I have. I am open to suggestions. Band 'A' SQL example is for all instruments. SQL's for 'B' and 'C' are just a samples of the whole thing.
    SQL for Band 'A'
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    ( ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Piccolo'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_piccolo from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Flute'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Flute from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Oboe'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Oboe from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'English_Horn'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Englishhorn from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'English_Horn'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Englishhorn from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Clarinet_Eflat'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Clarineteflat from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Clarinet'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Clarinet from festival_years where year = ':P6_YEAR')
    UNION ALL SELECT lname,fname,instrument,total FROM(SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank FROM band_students, festival_records A JOIN festival_records B on a.ID = b.ID where band_students.id = a.ID and a.instrument = 'Clarinet Bass' and a.festival_year = ':P6_YEAR' ORDER BY total, a.ID DESC NULLS LAST) WHERE Stu_Rank <= (select hb_Clarinetbass from festival_years where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Clarinet Contrabass'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Clarinetcontrabass from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Saxophone Alto'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Saxophonealto from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Saxophone Tenor'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Saxophonetenor from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Saxophone Bari'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Saxophonebari from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Bassoon'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Bassoon from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Bassoon Contra'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Bassooncontra from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Horn'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Horn from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Trumpet'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trumpet from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Trombone'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trombone from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Trombone Bass'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trombonebass from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Euphonium'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Trombonebass from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Tuba'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Tuba from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Percussion'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Percussion from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Piano'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Piano from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Violin'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Violin from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Viola'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Viola from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Cello'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Cello from festival_years
    where year = ':P6_YEAR')
    UNION ALL
    SELECT lname,fname,instrument,total
    FROM
    (SELECT lname, fname, a.instrument, a.total, DENSE_RANK() OVER
    (ORDER BY a.total DESC,a.ID NULLS LAST) AS Stu_Rank
    FROM band_students, festival_records A
    JOIN festival_records B on a.ID = b.ID
    where band_students.id = a.ID
    and a.instrument = 'Bass'
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank <= (select hb_Cello from festival_years
    where year = ':P6_YEAR'
    SQL for band 'B'
    SELECT lname,fname,instrument, total
    FROM
    (SELECT lname, fname, instrument, total, RANK() OVER
    ( ORDER BY instrument,total ASC NULLS LAST) AS Stu_Rank
    FROM festival_records, band_students
    where band_students.id = festival_records.id
    and instrument = 'Piccolo'
    and festival_year = '2014'
    ORDER BY instrument, total ASC NULLS LAST)
    WHERE Stu_Rank < (select hb_piccolo from festival_years
    where year = :P6_YEAR)
    SQL for band 'C'
    SELECT lname,fname,instrument, total
    FROM festival_records, band_students
    where band_students.id = festival_records.student_id
    and instrument = 'Piccolo'
    and festival_year = ':P6_YEAR'
    minus
    SELECT lname,fname,instrument, total
    FROM
    (SELECT lname, fname, instrument, total, RANK() OVER
    ( ORDER BY instrument,total DESC NULLS LAST) AS Stu_Rank
    FROM festival_records, band_students
    where band_students.id = festival_records.student_id
    and instrument = 'Piccolo'
    and festival_year = ':P6_YEAR'
    ORDER BY instrument, total DESC NULLS LAST)
    WHERE Stu_Rank < (select hb_piccolo from festival_years
    where year = ':P6_YEAR')
    SQL

    >
    Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already).
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    You should also always post code wrapped in <tt>\...\</tt> tags.
    I am trying to create a reportWhen asking a question about "reports" it's firstly essential to differentiate between standard and interactive reports. Which is it?
    but get a ORA-01461: can bind a LONG value only for insert into a LONG column error.Where and when do you get this error? When creating the report? Or running it?
    There's also an obvious bug (repeated many times):
    and a.festival_year = ':P6_YEAR'
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank &lt;= (select hb_piccolo from festival_years
                   where year = ':P6_YEAR')
    ...<tt>':P6_YEAR'</tt> is a literal string, not a bind variable reference. <tt>':P6_YEAR'</tt> seems an unlikely value for <tt>festival_year</tt> and <tt>year</tt> values. It should be:
    and a.festival_year = :P6_YEAR
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank &lt;= (select hb_piccolo from festival_years
                   where year = :P6_YEAR)
    ...or even better:
    and a.festival_year = to_number(:P6_YEAR)
    ORDER BY total, a.ID DESC NULLS LAST)
    WHERE Stu_Rank &lt;= (select hb_piccolo from festival_years
                   where year = to_number(:P6_YEAR))
    ...if the <tt>festival_year</tt> and <tt>year</tt> columns are of type NUMBER. There's a possibility that this bug is in fact the source of your error...
    Furthermore, this is a long piece of SQL. It may be that APEX can't cope with the length. However it's also very repetitive: we see the same SQL pattern repeated many times and UNIONed together. One way to reduce the length of the query would be to replace some (or all) of those repeating patterns. This will not only make the query more APEX-friendly, but it will probably be more efficient and easier to maintain too.
    I recommend that you Re: 2. How do I ask a question on the forums? that will enable others to have a go at this. Reproducing the app on apex.oracle.com and posting guest developer credentials would also be helpful.

  • Passing long values from inputItem to function  in backing bean

    hi,
    in my backing bean i intend to call function func1(Long pAmount)
    on my page there is an inputItem bound in the BB.
    So, in me backing bean i'd like to achieve long value (oracle db number(10,2)) from the bound text item.
    How can i get long value ? by default it's coming easy as Number ( (Number)(itPTPAmount.getValue()).toString())
    but even though i can't convert it to Long;
    what i have is going thru String, but this way below cuts fractions:
    try{
    ptpAmount=new Long((itPTPAmount.getValue()).toString());
    catch(Exception e){System.out.println("error ptpAmount:"+e.getMessage());return;}
    please advise

    you can use doubleValue()
    http://docs.oracle.com/cd/E12839_01/apirefs.1111/e10655/oracle/jbo/domain/Number.html#doubleValue%28%29

  • Detecting Number of Digits In An Int

    does anyone with experience in the fundamentals of java know how to detect the number of digits in an int
    i want to be able to detect the number of digits in a value recieved from a text box.
    i know i can use String.length() but i want to be able to do this in the same try block that catches a NumberFormatException after using
    int number = Integer.parseInt(s);
    thanks for any help

    i know i can use String.length() but i want to be
    able to do this in the same try block that catches a
    NumberFormatException after using
    int number = Integer.parseInt(s);What stops you from putting it there?
    Integer.toString(i).length(). Or the likes.

  • Error: PL/SQL ORA-00932 inconsistent datatype when using LONG value

    Good morning:
    I am using a work PL/SQL script where I am using a LONG value in a cursor. When I execute it, I am receiving:
    PL/SQL ORA-00932 inconsistent datatype:  expected NUMBER got LONG
    set serveroutput ON SIZE 1000000
    set heading off               
    set feedback off               
    set trimspool off              
    set echo off
    set term off                  
    set pagesize 0        
    SPOOL &so_outfile;
    DECLARE
      v_data_file          varchar2(30);
    --   v_sch_code            varchar2(10);
    --   v_instance_name       varchar2(10);
        ws_path            payroll.pybutfl.pybutfl_utl_file_path%TYPE;
        v_data_line           VARCHAR2 (2000)                              := NULL;
        fhandle_o             UTL_FILE.file_type;
        v_line_count          NUMBER                                       := 0;
        v_selected_count      NUMBER                                       := 0;
        v_error_count         NUMBER                                       := 0;
        v_written_count       NUMBER                                       := 0;
        v_error_text          VARCHAR2 (50)       := ' AMACONF_ERR: Unable to write the line. ';
        v_errm                VARCHAR2 (255);
        v_sqlerrm             VARCHAR2 (255);
        v_payment_type        VARCHAR2(10);
    CURSOR C1 IS
    select RTRIM
            AMRCONF_PIDM_ERR            ||'|'||
            AMRCONF_IDEN_CODE_ERR       ||'|'||
            AMRCONF_ENTRY_DATE_ERR      ||'|'||
            AMRCONF_CONFID_IND_ERR      ||'|'||
           *AMRCONF_COMMENT_ERR        ||'|'||*
            AMRSUBJ_SUBJ_CODE_ERR       ||'|'||
            ERROR_CODE                  ||'|'||
            ERROR_CODE_TEXT                 ) data_line
            from WSUALUMNI.AMRCONF_ERR;
    BEGIN
    DBMS_OUTPUT.put_line ('Program Generating AMACOMT Mass Update Error File ');
    IF UTL_FILE.is_open (fhandle_o)
        THEN  
       UTL_FILE.fclose (fhandle_o);
    END IF;
    /* Name The File Here */
    v_data_file := ('Amaconf_error.txt');
    SELECT RTRIM (pybutfl_utl_file_path)
          INTO ws_path
          FROM payroll.pybutfl;
          fhandle_o := UTL_FILE.fopen (ws_path, v_data_file, 'w');
          DBMS_OUTPUT.put_line ('UTLFILE file for this run is: ' || ws_path||'/'||v_data_file);
          v_written_count := 0;  
    FOR c1_rec IN C1 LOOP
          BEGIN
            v_selected_count := v_selected_count + 1;
            v_data_line := rtrim(c1_rec.data_line);
            UTL_FILE.put_line (fhandle_o, v_data_line);
            v_written_count := v_written_count + 1;
        EXCEPTION
         WHEN OTHERS
          THEN
           DBMS_OUTPUT.put_line (v_error_text);
           v_error_count := v_error_count + 1;
        END;
    END LOOP;
         DBMS_OUTPUT.put_line ('Number of Records Selected: ' || v_selected_count);
         DBMS_OUTPUT.put_line ('Number of Records Written: ' || v_written_count);
          IF UTL_FILE.is_open (fhandle_o)
          THEN
             UTL_FILE.fclose (fhandle_o);
          END IF;
    END;
    SPOOL OFF;If I comment out the "AMRCONF_COMMENT_ERR ||'|'||" line, then the script works fine. The table was created as:
    Create Table WSUALUMNI.AMRCONF_ERR
        AMRCONF_PIDM_ERR             NUMBER (8)    NOT NULL,
        AMRCONF_IDEN_CODE_ERR        VARCHAR2(5)   NOT NULL,
        AMRCONF_ENTRY_DATE_ERR       DATE          NOT NULL,
        AMRCONF_CONFID_IND_ERR       VARCHAR2(1),
        AMRCONF_COMMENT_ERR          LONG,         
        AMRSUBJ_SUBJ_CODE_ERR        VARCHAR2(5)   NOT NULL,
        ERROR_CODE                   VARCHAR2(12)  NOT NULL,
        ERROR_CODE_TEXT              VARCHAR2(50)  NOT NULL
    ); I don't get what is the problem here in the script.

    Hi,
    Feew suggestions
    1) LONG is a deprecated type hence if possible start working on changing that column
    2) CLOB will your preferred datatype over LONG.
    3) you cannot use RTRIM on long.
    here is a very quick example
    drop table h
    create table h (x long,y varchar2(100))
    select rtrim(x) from h
    select rtrim(y) from hSolution:
    [http://www.oracle.com/technology/oramag/code/tips2003/052503.html]
    need a better solution change the datatype to clob and
    drop table h
    create table h (x clob,y varchar2(100))
    select  dbms_lob.substr( x, 4000, 1 ) from h
    select rtrim(y) from hCheers!!!
    Bhushan

  • Can't activate - activation does not have the required number of digits

    I have an old paid version of CS that I have been using for years. I recently had my hard drive repaired and they managed to deactivate my CS. When I try and do the phone activation, after I enter the activation code it says "The number you entered does not have the required number of digits". I am reading it right off the screen in front of me. The only other info is activation type = repair. What are my options? I paid a lot for this and I would like to keep using it. Thanks for any help.

    I am having the exact same problem. I have moved my Adobe CS3 to a new computer. Even though I am entering the activation code correctly as displayed on my screen, I still get the message "The number you entered does not have the required number of digits". You can then select to speak to someone, but then you receive a recording that Adobe is no longer handling activation problems via phone, goodbye, and I am disconnected.
    How can I re-activate my CS3 product? I have a legitimate purchase and a legitimate license key. Thank you.

  • ORA-01461 can bind a LONG value only for insert into a LONG

    I Use ODP.net Insert and update Image files to Oralce blob columns(Oracle8i Server,ora92 client),
    When the files larger than 4000 characters,It doesn't work.error:ORA-01461 can bind a LONG value only for insert into a LONG
    My Vb.net code:
    Dim dlg As OpenFileDialog
    Dim strFileName() As String
    Dim fsBLOB As System.IO.FileStream
    Dim Adapter As OracleDataAdapter
    Dim ds As New DataSet
    Dim row As DataRow
    Dim cb As OracleCommandBuilder
    Dim bytes() As Byte
    dlg = New OpenFileDialog
    dlg.Filter = "Import File (*.*)|*.*"
    Adapter = New OracleDataAdapter("select * from a_blob_contents where 1=0", Me.OraConnection)
    Adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
    Adapter.FillSchema(ds, SchemaType.Source, "BLOB")
    cb = New OracleCommandBuilder(Adapter)
    If dlg.ShowDialog() = DialogResult.OK Then
    strFileName = dlg.FileNames()
    Dim loopCount As Integer
    For loopCount = 0 To strFileName.GetLength(0) - 1
    row = ds.Tables("BLOB").NewRow()
    row("BLOB_ID") = GetMaxBh("A_BLOB_CONTENTS", "BLOB_ID")
    row("FILE_ID") = FileID
    row("FILE_TYPE") = FileType
    Dim file_name As String
    file_name = strFileName(loopCount)
    file_name = file_name.Substring(file_name.LastIndexOf("\") + 1, file_name.Length - file_name.LastIndexOf("\") - 1)
    row("BLOB_NAME") = file_name
    fsBLOB = New FileStream(strFileName(loopCount), FileMode.Open, FileAccess.Read)
    ReDim bytes(fsBLOB.Length)
    fsBLOB.Read(bytes, 0, System.Convert.ToInt32(fsBLOB.Length))
    fsBLOB.Close()
    row("blob_contents") = bytes
    row("user_code") = Global.user_code
    row("Operate_date") = Now
    ds.Tables("BLOB").Rows.Add(row)
    Next
    Try
    Adapter.Update(ds, "BLOB")
    Catch ex As Exception
    MessageBox.Show(ex.Message)
    End Try
    End If
    I'll appreciate for anyone who can help me solve this problem.

    Hi Zhenquan,
    The issue is that you can not direct insert more than 4K (as you have discovered). Two methods I use in this situation are:
    1) sql statement or procedure that returns a lob locator into an ODP.NET OracleBlob parameter such as:
    insert into the_table (primary_key, blob_column) values (pk_value, empty_blob()) returning blob_column into :blob_parameter.
    Once you have the OracleBlob you should be able to write/update the data.
    2) use an anonymous pl/sql block or package that uses the dbms_lob supplied package to work with the LOB.
    Here is a simple console example...
    SQL> create table blob_test
    2 (
    3 blob_id number,
    4 blob_data blob,
    5 constraint blob_test_pk primary key (blob_id)
    6 )
    7 tablespace users;
    Table created.
    Sub Main()
    Dim strFileName As String = "c:\temp\testimage.jpg"
    Dim fsBlob As FileStream = New FileStream(strFileName, FileMode.Open)
    Dim bytes(fsBlob.Length) As Byte
    fsBlob.Read(bytes, 0, fsBlob.Length)
    fsBlob.Close()
    Dim con As OracleConnection = New OracleConnection("User Id=/; Data Source=lt8i")
    con.Open()
    Dim trans As OracleTransaction = con.BeginTransaction()
    Dim sql As String = "insert into blob_test (blob_id, blob_data) values (1,empty_blob()) returning blob_data into :blob_parameter"
    Dim blob_parameter As OracleParameter = New OracleParameter
    blob_parameter.OracleDbType = OracleDbType.Blob
    blob_parameter.Direction = ParameterDirection.InputOutput
    Dim cmd As OracleCommand = New OracleCommand(sql, con)
    cmd.Parameters.Add(blob_parameter)
    cmd.ExecuteNonQuery()
    Dim blob As OracleBlob = blob_parameter.Value
    blob.Write(bytes, 0, bytes.Length)
    sql = "update blob_test set blob_data = :blob_parameter where blob_id = 1"
    cmd.CommandText = sql
    blob_parameter.Value = blob
    cmd.ExecuteNonQuery()
    trans.Commit()
    End Sub
    This sample was tossed together pretty quickly, so it is not a complete, bullet-proof sample, but hopefully it will give you what you need to get started. The 'testimage.jpg' file is just over 5MB in size.
    Hope that helps,
    Mark
    =======================================
    Mark A. Williams
    Oracle DBA
    Author, Professional .NET Oracle Programming
    http://www.apress.com/book/bookDisplay.html?bID=378

Maybe you are looking for