Menu

OCI_ColumnGetScale return zero for TO_NUMBER

CHON TEH
2011-12-26
2012-09-26
  • CHON TEH

    CHON TEH - 2011-12-26

    Hi Vincent,

    select to_number('$99.64', 'L99D99') from dual

    Inside my program, I use OCI_ColumnGetScale to identify OCI_CDT_NUMERIC
    is Double or Integer.
    If the scale > 0, i use the
    double d = OCI_GetDouble(rs, index);
    else
    int i = OCI_GetInt(rs, index);

    From the above statement, i expect the scale is 2.
    but it return 0 for OCI_ColumnGetScale.
    Is this a bug or how to identify the column is double or integer for
    TO_NUMBER() ?

    Thank

    Alvin Teh

     
  • Vincent Rogier

    Vincent Rogier - 2011-12-26

    What is your version of Oracle (scale and precision values differs depending
    the version of oracle) ?
    I'll test your code this evening and check the real values retrieved form OCI.

     
  • Vincent Rogier

    Vincent Rogier - 2011-12-26

    to_number() returns a "NUMBER" with no precision on its scale or precision.

    Here is the definition from Oracle of a the type NUMBER with no precision /
    scale :

    The absence of precision and scale designators specifies the maximum range
    and precision for an Oracle number.

    Thus to_number() is returning a NUMBER and not a "specialised" version of a
    NUMBER depending on the given format.

    OCILIB retrieves form OCI client is this case 0 for scale and 0 for precision.

    It is not possible to find out the "range" of the value contained inside a
    NUMBER as NUMBER allows all possible values.

    Regards,

    Vincent

     
  • CHON TEH

    CHON TEH - 2011-12-27

    Thank a lot.
    You are correct, the oracle oci didn't provide scale for compute field ( eg:
    avg,min,max,to_number..).
    I will handle it on my program.

    Regards,
    Alvin Teh