NUMBER Data type's Negative Scale

This is what I read in the 1z0-051 Study Guide:
The NUMBER data type may optionally be qualified with a precision and a scale. The precision sets the maximum number of digits in the number, and the scale is how many of those digits are to the right of the decimal point. If the scale is negative, this has the effect of replacing the last digits of any number inserted with zeros, which do not count toward the number of digits specified for the precision. If the number of digits exceeds the precision, there will be an error; if it is within the precision but outside the scale, the number will be rounded (up or down) to the nearest value within the scale. I am not sure if I understood this paragraph the correct way or not and hence this query:
I created this table t1
create table t1
(col1 number,
col2 number(4),
col3 number(4,2),
col4 number(4,-2));
INSERT INTO T1 (COL4) VALUES (1234); = 1200 is inserted
INSERT INTO T1 (COL4) VALUES (12.34); = 0 is inserted
INSERT INTO T1 (COL4) VALUES (12345.34); = 12300 is inserted. Should is not throw an error as the whole value should be of length 4 (including the precision).
However, INSERT INTO T1 (COL4) VALUES (123456789.34); throws error.How is this working? Please help!
Edited by: TuX4EvA on Sep 29, 2009 4:12 AM

Please, observe the following example:
CREATE TABLE test1
col1 NUMBER (6, 2),
col2 NUMBER (6, -1),
col3 NUMBER (6, -2),
col4 NUMBER (6, -3)
INSERT INTO test1 (col1, col2, col3, col4) VALUES (1234.89, 1234.89, 1234.89, 1234.89);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (1000.89, 1000.89, 1000.89, 1000.89);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (2020.02, 2020.02, 2020.02, 2020.02);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (56, 56, 56, 56);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (56.89, 56.89, 56.89, 56.89);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (20.89, 20.89, 20.89, 20.89);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (49.89, 49.89, 49.89, 49.89);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (50.89, 50.89, 50.89, 50.89);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (501.89, 501.89, 501.89, 501.89);
INSERT INTO test1 (col1, col2, col3, col4) VALUES (158.23, 158.23, 158.23, 158.23);
COMMIT;
SELECT * FROM test1;When you select from the table, you will receive:
        col1          col2         col3     col4
   1234,89           1230           1200     1000
   1000,89           1000           1000     1000
   2020,02           2020           2000     2000
        56             60            100     0
     56,89             60            100     0
     20,89             20              0     0
     49,89             50              0     0
     50,89             50            100     0
    501,89            500            500     1000
    158,23            160            200     0From this example and according to the oracle documentation SQL Reference one could see that scale equal to -1 means to round the precision to the tens, -2 means to the hundreds, -3 - to the thousands and so on. But I cannot say it as well as it is said on page 44 from [Oracle Database SQL Reference|http://download.oracle.com/docs/cd/B19306_01/server.102/b14200.pdf].
Hope it was useful :)

Similar Messages

  • Data_length of number data type

    when I checked for the columns with data type as number in dba_tab_cols it is showing 22 for all the columns irrespective of the precision and scale. why is it so?
    also can you tell what data length exactly means?
    Edited by: user12288160 on May 19, 2010 3:04 AM

    Hi tom,
    I am doing database sizeing. I am expecting that one of my table will have 50,000,000 records in
    future(say within 6 month). That table has composite primary key(5 columns). All the columns are
    NUMBER data type. In All_tab_column I could see the data length is always 22. So I tried to
    decrease the length( Number(10)). Then also its saying data length is 22. But I Know that I can't
    enter data in this field more than 10 digits. So In this case it should be 12. But why its showing
    22(Data_length field in All_tab_columns).
    My question is, for my sizeing calculation, should I take this length 12 or 22?.
    Thanks
    Followup August 12, 2004 - 9am Central time zone:
    that is the max length -- numbers are stored as varying length character strings.
    Source: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1619552483055
    REgards
    Asif Kabir

  • What is the size of number data type.

    what is the size of number data type (in term of memory storage ;byte ).
    Does it make different in size if mention number(38,0)?
    Thanks all in advance...:)
    Edited by: user10648897 on Jan 7, 2009 6:43 AM

    NUMBER (p,s)
    Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127.number(38,0) = number(38)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14196/schema002.htm#sthref472

  • Ho to Comapre with Number Data Type

    hi
    My reqt is to do validation in ValidateEntity Method.
    How to compare the with Number Data type:
    For ex: Number a = gatAbc();
    If(a>10)
    throw new oaExcption...
    But while comapring i got compiler Error
    Error(218,17): method >(oracle.jbo.domain.Number, int) not found in class abc.oracle.apps.per.irc.pqr.schema.server.XxabcEOImpl
    So plz tell me how to compare the integer value with Number data type
    Thanx

    Check with float. It will work definitely.
    float number = Float.parseFloat(HrsPerDay); //HrsPerDay is a String and I am converting it to float
    if(( number <= 0) || (number >= 21))
                            throw new OAAttrValException(OAAttrValException.TYP_VIEW_OBJECT,
                                              "xxCopyResourceVO1",
                                              rowi.getKey(),
                                              "NoOfCopies",
                                              rowi.getAttribute("NoOfCopies"),
                                              "PA",
                                              "xx_xx_COPY_POSITIVE_NUM");
                       }Here in this code i am also checking that the Hours cannot be less then 0 and greater than 20.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • About Number Data type

    Hi All,
    I have few issues with "Number" data type
    1) trying to convert string "0.0000007" to Number i am getting value with exponential (1e-7). This is only when we have more than 5 0's after decimal.
    2) If i try to do below calculation, i am not getting exact value:
    ex: 999999.999999+999999999999=1000000999999-999999999999 = 1000000(expected should be:999999.999999)
    0.3*6=1.79999998 (exact value: 1.8)
    Please let me know what might be the issue......
    Thanks in advance to all....

    That's standard behavior for floating point.  If you search the forum for
    past discussions of floating point and Number you'll see explanations why.
    To get displayable strings, use toPrecision or toFixed

  • Number data type and schematool kodo2.3.3

    Hi!
    I have a class that has a data member of type 'Number' (java.lang.Number).
    When I run the 'schematool' to generate the tables in the datastore, it
    seems to ignore this Number field. If i change the type to Integer or
    Float, and then run schematool, a corresponding column is correctly
    created in the table in the database. Is there anything special that needs
    to be indicated in the metadata file for Number data types?
    Thanks
    Vijay

    I have a class that has a data member of type 'Number' (java.lang.Number).
    When I run the 'schematool' to generate the tables in the datastore, it
    seems to ignore this Number field.It's pretty strnage, but the Number type isn't mentioned as a supported
    persistent type in the JDO specification, and so Kodo doesn't yet support
    it. I say it's strange because as you pointed out, all concrete subclasses
    of Number are supported: Integer, Float, Double, BigDecimal, BigInteger,
    etc.
    We recently realized this oversite ourselves, and so supporting Number fields
    is on our to-do list. For the time being, however, you're stuck with
    declaring the field to be some conrete type.

  • Wat should be data type for  negative and decimal values (eg: -1.2222)

    What should be data type for  negative and decimal values (eg: -1.2222)

    Hi
    U can use the data type DEC while creating the DOMAIN and in the domain u  have sign check box at the left corner of the screen, click that check box , u can assign negative values for the field which refers this domain.
    REWARD IF HELPFULL
    Anees.

  • Loading unpacked Zoned data into NUMBER data types

    I need to use SQL*Loader to load data created on an MVS machine (EBCDIC) which is FTP'd to AIX (converted to ASCII during the FTP). Some of the data elements have signed unpacked numeric data. These need to be loaded into two types of fields in Oracle - 1) defined as data type NUMBER(19) 2) - defined as data type NUMBER (38,2) (i.e. dollar field with 2 decimal positions). For the dollar data I am loading there is an implied decimal. I need to know how to code SQL*Loader statements to handle these two situations. Because I have zoned unpacked source the resulting data loaded into the table must have a trailing sign (only if negative). Also the dollar fields need to have an explicit decimal inserted - and these dollar fields could also end up being negative.
    Any help would be appreciated. Various google searches have not given me the answers I need.

    979755 wrote:
    Most helpful. Pardon a few follow-on questions:
    1. The Zoned definition refers (I hope) to the data on the input file - regardless of the definition of the field field being loaded in the table (in my case the field in the table is defined as NUMBER) - is this a true statement?
    True, in your controlfile you set (for example): , zonedCol POSITION(x:y) ZONED(precision,scale)
    2. If I am correct on item 1, if I have a negative number in the input file (let's say a negative 10) is a trailing sign loaded into the database (so it will be 10-)?
    NO, to deal with signed numbers, you set trailing signs as table column in a staging table and then apply to real table.
    3. What happens to any leading zeroes when the data is loaded into the table?
    Ignored.
    4. For dollar fields where the source has an implied decimal but I want an implicit decimal in loaded into the table and the number can be positive or negative, can I specify this as ZONED (10.2) in the control file?
    See answer #2.
    ZONED (10,2) implies field is 10 characters long and the last two are decimals.
    5. And finally, regarding item 4 my understanding is that ZONED (10.2) would result in 12345678.12 (with a negative sign if appropriate) - is this a correct understanding?
    Nope, only the digits. That is why we use staging table to capture the sign.
    PS: The best would be to create external table on the source file.
    Edited by: L-MachineGun on Jan 4, 2013 3:12 PM

  • How to handle NUMBER data type of SQL

    Hello All,
    I have to call an Oracle store procedure developed by 3rd party, it has once of the input parameter as NUMBER.
    Since NUMBER SQL data type is not support by PI 7.0 (http://help.sap.com/saphelp_nwpi71/helpdata/EN/44/7b72b2fde93673e10000000a114a6b/content.htm),
    when I am execute this scenario, it through an error for - Unsupported parameter type 'NUMBER'.
    I cannot change the store procedure or any thing in Oracle.
    I gone through some thread but did not find any help. NUMBER type for Oracle SP
    Please let me know if there any work around.
    Thanks in Advance.
    Pradeep

    Thanks for your reply.
    I cannot customize the stored procedure parameter to NUMERIC, as this is standard SP is from a product.
    Below is the final XML generated with error on PALC and PREL parameter for NUMBER, ideally it should be
    <PALC isInput="true" type="NUMBER"/>
    <PREL isInput="true" type="NUMBER"/>
    <Statement xmlns="">
    <LSA_REL_DM action="EXECUTE">
        <table>ACQDR.lsa_rel_dm</table>
          <PPROJECTID isInput="true" type="VARCHAR">85LJ24210</PPROJECTID>
          <PDMC isInput="true" type="VARCHAR">LJ200-A-J00-00-00-00-00AAA-00K-AA</PDMC>
          <PLCN isInput="true" type="VARCHAR"/>
          <PALC isInput="true"/>     
          <PTYPE isInput="true" type="CHAR"/>
          <PSOURCE_CODE isInput="true" type="VARCHAR"/>
          <PREL isInput="true"/>     
          <PRFU isInput="true" type="VARCHAR"/>
          <POBJECT isInput="true" type="BLOB">&lt;dmodule xsi:noNamespaceSchemaLocation="C:/Projects/S1000D/Document/schema/TIR_Parts_Vendors.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;identAndStatusSection&gt;&lt;dmAddress&gt;&lt;dmIdent&gt;&lt;dmCode modelIdentCode="LJ200" systemDiffCode="A" systemCode="J00" subSystemCode="00" subSubSystemCode="00" assyCode="00" disassyCode="00" disassyCodeVariant="AAA" infoCode="00K" infoCodeVariant="A" itemLocationCode="A"/&gt;&lt;language languageIsoCode="US" countryIsoCode="sx"/&gt;&lt;issueInfo issueNumber="0" inWork="1"/&gt;&lt;/dmIdent&gt;&lt;dmAddressItems&gt;&lt;issueDate year="20111107" month="20111107" day="20111107"/&gt;&lt;dmTitle&gt;&lt;techName&gt;General&lt;/techName&gt;&lt;infoName&gt;Organizations technical information repository&lt;/infoName&gt;&lt;/dmTitle&gt;&lt;/dmAddressItems&gt;&lt;/dmAddress&gt;&lt;dmStatus&gt;&lt;security securityClassification="01"/&gt;&lt;responsiblePartnerCompany enterpriseCode="24210"&gt;&lt;enterpriseName&gt;Learjet&lt;/enterpriseName&gt;&lt;/responsiblePartnerCompany&gt;&lt;originator enterpriseCode="24210"&gt;&lt;enterpriseName&gt;Learjet&lt;/enterpriseName&gt;&lt;/originator&gt;&lt;applicCrossRefTableRef&gt;&lt;dmRef&gt;&lt;dmRefIdent&gt;&lt;dmCode modelIdentCode="LJ200" systemDiffCode="A" systemCode="J00" subSystemCode="0" subSubSystemCode="0" assyCode="00" disassyCode="00" disassyCodeVariant="A" infoCode="00W" infoCodeVariant="A" itemLocationCode="A"/&gt;&lt;/dmRefIdent&gt;&lt;/dmRef&gt;&lt;/applicCrossRefTableRef&gt;&lt;brexDmRef&gt;&lt;dmRef&gt;&lt;dmRefIdent&gt;&lt;dmCode modelIdentCode="LJ200" systemDiffCode="A" systemCode="J00" subSystemCode="0" subSubSystemCode="0" assyCode="00" disassyCode="00" disassyCodeVariant="A" infoCode="022" infoCodeVariant="B" itemLocationCode="D"/&gt;&lt;/dmRefIdent&gt;&lt;/dmRef&gt;&lt;/brexDmRef&gt;&lt;/dmStatus&gt;&lt;/identAndStatusSection&gt;&lt;content&gt;&lt;techRepository&gt;&lt;partRepository/&gt;&lt;/techRepository&gt;&lt;/content&gt;&lt;/dmodule&gt;</POBJECT>
            <PSTATUS isInput="true" type="CHAR">D</PSTATUS>
            <PISSTYPE isInput="true" type="CHAR"/>
            <POBJECT_CLASS isInput="true" type="VARCHAR">XML</POBJECT_CLASS>
        </LSA_REL_DM>
    </Statement>
    Thanks in Advance

  • Table Functions, Direct Database Requests, and NUMBER data types

    Hello. I call a number of table functions from our BI Enterprise server, and I've elected to do so using Direct Database Requests (I believe you can also call table functions in the physical layer of the repository, but that's not what I'm doing). The problem is that whenever I return any number from the table function that is not a whole number (1.23, for example), BI assigns the INTEGER datatype to the field instead of the DOUBLE datatype, thereby rounding my number to the nearest integer. Here's a concise example:
    Create these 3 database objects:
    CREATE OR REPLACE TYPE my_row AS OBJECT (my_num NUMBER);
    CREATE OR REPLACE TYPE my_tab AS TABLE OF my_row;
    CREATE OR REPLACE FUNCTION my_table_function RETURN my_tab
    PIPELINED IS
    BEGIN
    PIPE ROW(my_row(1.23));
    END;
    Then make this your query in your Direct Database Request:
    SELECT my_num FROM table(my_table_function);
    That query correctly returns "1.23" when it's called from the database. In BI, on the other hand, it returns "1" (and labels the field an INTEGER instead of DOUBLE data type). If in the Direct Database Request you change the Column Properties ->Data Format -> Decimal Places from 0 to 2, it then not surprisingly displays "1.00". I then tried changing MY_ROW.MY_NUM's datatype by explicitly specifying precision, and no luck. BI still labels this field as an INTEGER. Then I started trying to trick BI by massaging the SQL statement itself. None of the following worked:
    SELECT to_number(my_num) as my_num2 FROM table(my_table_function);
    SELECT my_num2 + 0.01 as my_num3 FROM (SELECT my_num - 0.01 AS my_num2 FROM table(my_table_function));
    SELECT to_number(to_char(my_num)) as my_num2 FROM table(my_table_function);
    SELECT to_number(substr(to_char('x'||my_num),2)) as my_num2 FROM table(my_table_function);
    Now I did find a solution, but I'm surprised that I have to resort to this:
    SELECT * FROM (SELECT /*+ NO_MERGE */ my_num FROM table(my_table_function));
    Does anyone out there know of a better way to do this? The above is a hack in my opinion. :)
    Thanks in advance for any input.
    -Jim

    Yes, it's really amazing.
    But I got it.
    CREATE OR REPLACE TYPE my_row AS OBJECT (my_num NUMBER(10,2));and in your SQL :
    SELECT cast(my_num as double precision) as my_num2 FROM table(my_table_function);I have the good result and I see the numbers after the comma.
    Very tricky !
    Edited by: gerardnico on Jul 7, 2009 2:55 PM change number(10,2) by double precision ......... pfffff

  • Adding scale to a number data type

    I have a current column that is Number(22) that has many rows in it. I would
    like to keep the 22 and add 2 to the scale, can this be done on the fly????

    Why not try
    ALTER TABLE a MODIFY num_col NUMBER( 24, 2);
    and see what happens. If it works you are done. If not add a column number(24,2), update the table to set the new column = to the old column, alter that table to drop the old column, alter the table to rename the new column to the old columns name. Or set the old column null, modify it, update back to it from the new column, then drop the new column, or use DBMS_REDEFINITION.
    It is well to try something before coming here for a solution. Then tell us what you have tried and the results.

  • Number data-type saving problem through PL/SQL

    hi,
    I am having a field in my table called "amount" with type number(17,3). I am facing some problem while saving the data through pl/sql developer.
    while i am inserting data like 123456789012.567 its working fine but when I am inserting 1234567890123.567 for amount field its now showing any error while saving, but actually its storing "1234567890123.570" in DB. Similar thing is happening when I was saving "12345678901234.567",actually its saving "12345678901234.600".
    Whenever I was getting for 17 digits it's rounding last 3 and for 16 its rounding 2.
    I am using oracle10g as DB server.
    please suggest how to solve this particular problem as i am stuck or the alternate ways...
    Thanks,
    Shouvik

    It is a display problem, not a storage problem. i'm not sure what the equivalent in PL/SQL Developer is, but this sqlplus example seems to replicate your stated issue.
    SQL> create table t (num number(17,3));
    Table created.
    SQL> insert into t values (123456789012.567);
    1 row created.
    SQL> insert into t values (1234567890123.567);
    1 row created.
    SQL> insert into t values (12345678901234.567);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> set numwidth 16
    SQL> select * from t;
                 NUM
    123456789012.567
    1234567890123.57
    12345678901234.6
    SQL> set numwidth 25
    SQL> /
                          NUM
             123456789012.567
            1234567890123.567
           12345678901234.567You need to expand the display width for numbers.
    John

  • Migrate SqlServer BigInt DataType to Ora Number data type - customizable ?

    Hello,
    i'm trying to migrate a sql-server 2005 db to oracle 10 using Sql-Developer v 1.2.0.
    Every column having datatype bigint is converted to a Number(10,0) column.
    Is it possible to customize this convertion cause i would like to have a Number(19,0) column ?
    Thanks in adavance !

    SQL> desc emp_test;
    Name                                                                                Null?    Type
    EMPNO                                                                                        NUMBER(6)
    ENAME                                                                                        VARCHAR2(20)
    JOB                                                                                          VARCHAR2(9)
    MGR                                                                                          NUMBER(4)
    HIREDATE                                                                                     DATE
    SAL                                                                                          NUMBER(7,2)
    COMM                                                                                         NUMBER(7,2)
    DEPTNO                                                                                       NUMBER(2)

  • Decimal data type with negative sign

    Hi Gurus,
    I wanted to created a z table with a filed of type decimal with sign.  What I did is I created a field in predifined type with dec type, but -ve sign is not taking at the time of entering the data in SM30. Its saying only +ve values are allowed. Please let me know how can I achieve this. My data will be like -4.1242.
    Thanks,
    David.

    Hi..
    Try using another field as an indicator for negative fields so that you can consider those signs in your program.
    Regards,
    Karthik

  • Error;invaild number. different data type: how to insert

    In testtable, ID(number(12), amount(number(12))
    Now I want to insert the following record. I got error,a invalid number .
    insert into testtable(id,amount) values('111','9,000.00');
    I think data type is different. amount is number type but '9,000.00' is varchar2.
    How can i insert '9,000.00' to number data type?
    I do insert to_number('9,000.00'). It doesn't work.
    Would you help me for this problem.

    as amount is a number field it will only take data of type number only.so if ue data is not number type u need to convert it to number and insert it.
    however u can select it in the same format(original),using something like this:
    SQL> SELECT ename employee, TO_CHAR(sal, '99,990.99') from emp;
    EMPLOYEE TO_CHAR(SA
    SMITH 800.00
    ALLEN 1,600.00
    WARD 1,250.00
    JONES 2,975.00
    MARTIN 1,250.00
    BLAKE 2,850.00
    CLARK 2,450.00
    SCOTT 3,000.00
    KING 5,000.00
    TURNER 1,500.00
    ADAMS 1,100.00
    EMPLOYEE TO_CHAR(SA
    JAMES 950.00
    FORD 3,000.00
    MILLER 1,300.00
    14 rows selected.

Maybe you are looking for

  • Can I suppress HTML escaping in a read-only item?

    I have an item that is displayed as read-only. The item contains HTML markup. HTML DB seems to automatically escape special characters in the item value. Is there a way to suppress this? For example, I have a text input item with the value: <b>Hello<

  • "Taken on" date in Flickr incorrect

    I noticed a weird behavior with some Aperture photos I post to Flickr.  If I follow the steps below, the "taken on" date shown in Flickr is always incorrect (details later). - Upload RAW files (this happens with Canon G12 and also Nikon D300) into Ap

  • Is There a server to store acrobat collaborative documents on?

    have acrobat 9 on XP. Is there a server or space I can rent (if I have to)...to be able to collaborate on a document with 5 people.  I want all 5 people to be able to comment on a common shared document and to see eachothers comments to the same ques

  • InDesign Update isn't opening file

    Hey so my boss sent me an InDesign file and my creative cloud says my Indesign is up to date but when I try to open her file it says I need to work in a later version of InDesign. I'm working on a PC and she works off a Mac, does that have anything t

  • Hi iwant to execute 3 reports at one time

    Hi Friends,       Actually iam getting one issue as they r given 3 reports so iwant to execute the 3 reports at one time ie... i waant to execute the two reports from the first one ok      So iwant the solution for this one so pls provide the solutio