TO_NUMBER getting invalid number error

I want to use TO_NUMBER function to converse some float number,
but the following query always gets invalid number error:
select to_number('12.1073') from dual;
but if I add the format in, it runs as expected:
select to_number('12.1073', '99.9999') from dual;
From the syntax, the format parameter is optional, is it only optional for integers?
Thanks!

Same here.
So, or you replace dot by comma, or you change the territory (or nls_numeric_characters) defined for your session :
SQL> select to_number('12.1073') from dual;
select to_number('12.1073') from dual
ERROR at line 1:
ORA-01722: invalid number
Elapsed: 00:00:00.00
SQL> alter session set nls_territory='america';
Session altered.
Elapsed: 00:00:00.00
SQL> select to_number('12.1073') from dual;
TO_NUMBER('12.1073')
             12.1073
Elapsed: 00:00:00.00
SQL> alter session set nls_territory='france';
Session altered.
Elapsed: 00:00:00.00
SQL> select to_number('12.1073') from dual;
select to_number('12.1073') from dual
ERROR at line 1:
ORA-01722: invalid number
Elapsed: 00:00:00.00
SQL> alter session set nls_numeric_characters='.,';
Session altered.
Elapsed: 00:00:00.00
SQL> select to_number('12.1073') from dual;
TO_NUMBER('12.1073')
             12.1073
Elapsed: 00:00:00.00
SQL> Nicolas.

Similar Messages

  • Please help getting invalid number error.

    Hi Experts,
    My requirement is
    If DT_ID value of xmlmsg existed in the DT_ID of PART_ID_COLLES table then that record should be processd else should be skipped.
    And xmlmsg of PART_ID should start with "A" and followed only by the number then that record should be processed else should be skipped.
    And xmlmsg of DD_DAYS should contain only  the number and grater than or equal to 0 ,then that record should be processed else should be skipped.
    For that I have written this code.
    But if I pass dt_id as string value in xmlmsg I am getting invalid number error.
    DT_ID of PART_ID_COLLES table is number data type.
    SELECT xmlmsg.part_id part_id,xmlmsg.dd_days dd_days,xmlmsg.dt_id dt_id
                      FROM XMLTABLE(
                            XMLNAMESPACES(
                                'urn:schemas-microsoft-com:rowset' as "rs"
                              , '#RowsetSchema' as "z"
                            '/z:row[not(@dt_id=following-sibling::z:row/@dt_id and @part_id=following-sibling::z:row/@part_id)]'
                            PASSING p_dd_days_vals
                            COLUMNS
                                ITEM_NO             for ordinality
                              , dt_id    VARCHAR2 (20) path '@dt_id'
                              , part_id  VARCHAR2 (25) path '@part_id'
                              , dd_days  VARCHAR2 (20) path '@dd_days'
                           ) xmlmsg,
                           part_id_colles pic
                           WHERE REGEXP_REPLACE(TRIM(xmlmsg.dt_id),'^([0-9]+)$|.','\1') = pic.dt_id
                                 AND REGEXP_LIKE (UPPER(TRIM(xmlmsg.part_id)),'^[A][0-9]+$')
                                 AND (TO_NUMBER(REGEXP_REPLACE(TRIM(xmlmsg.dd_days),'^([0-9]+)$|.','\1')) >=0
                                 AND REGEXP_LIKE(TRIM(xmlmsg.dd_days), '^-?[[:digit:],.]*$') ;
    Sample message is
    <MESSAGES>
    <MESSAGE ID="12345">
      <MSG_ID>3026900</MSG_ID>
      <DT_POSTED>6/20/2013 08:15:48</DT_POSTED>
      <POSTED_BY>GPD_MSG_EXTRACTOR</POSTED_BY>
      <DT_LAST_QUEUED />
    <MSG>
    <WORK_SET TRANSACTION_ID="@TRANS_ID" TRANSACTION_TYPE="Batch" IS_ACID="@IS_ACID">
    <WORK_UNIT GROUP="dd_days" ACTION="ADD" AFFECTED="dd_days">
    <RECORDSET TABLE_NAME="dd_days">
    <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
    <rs:data>
      <z:row dt_id="430" part_id="A5556689" dd_days="10"/>
      <z:row dt_id="550A" part_id="A8889965" dd_days="20"/>
      </rs:data>
      </xml>
      </RECORDSET>
      </WORK_UNIT>
      </WORK_SET>
      </MSG>
      </MESSAGE>
      </MESSAGES>
    Please help me.
    Thanks.

    Your code has ton of errors. Anyway:
    with part_id_colles as (
                            select 430 dt_id,xmltype('<MESSAGES>
    <MESSAGE ID="12345">
      <MSG_ID>3026900</MSG_ID>
      <DT_POSTED>6/20/2013 08:15:48</DT_POSTED>
      <POSTED_BY>GPD_MSG_EXTRACTOR</POSTED_BY>
      <DT_LAST_QUEUED />
    <MSG>
    <WORK_SET TRANSACTION_ID="@TRANS_ID" TRANSACTION_TYPE="Batch" IS_ACID="@IS_ACID">
    <WORK_UNIT GROUP="dd_days" ACTION="ADD" AFFECTED="dd_days">
    <RECORDSET TABLE_NAME="dd_days">
    <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
    <rs:data>
      <z:row dt_id="430" part_id="A5556689" dd_days="10"/>
      <z:row dt_id="550A" part_id="A8889965" dd_days="20"/>
      </rs:data>
      </xml>
      </RECORDSET>
      </WORK_UNIT>
      </WORK_SET>
      </MSG>
      </MESSAGE>
      </MESSAGES>') p_dd_days_vals from dual)
    SELECT  xmlmsg.part_id part_id,
            xmlmsg.dd_days dd_days,
            xmlmsg.dt_id dt_id
      FROM  part_id_colles pic,
            XMLTABLE(
                     XMLNAMESPACES(
                                   'urn:schemas-microsoft-com:rowset' as "rs",
                                   '#RowsetSchema' as "z"
                     '/MESSAGES/MESSAGE/MSG/WORK_SET/WORK_UNIT/RECORDSET/xml/rs:data/z:row[not(@dt_id=following-sibling::z:row/@dt_id and @part_id=following-sibling::z:row/@part_id)]'
                     PASSING p_dd_days_vals
                     COLUMNS
                        ITEM_NO             for ordinality,
                        dt_id    VARCHAR2 (20) path '@dt_id',
                        part_id  VARCHAR2 (25) path '@part_id',
                        dd_days  VARCHAR2 (20) path '@dd_days'
                    ) xmlmsg
      WHERE REGEXP_REPLACE(TRIM(xmlmsg.dt_id),'^([0-9]+)$|.','\1') = pic.dt_id
        AND REGEXP_LIKE(UPPER(TRIM(xmlmsg.part_id)),'^[A][0-9]+$')
        AND TO_NUMBER(REGEXP_REPLACE(TRIM(xmlmsg.dd_days),'^([0-9]+)$|.','\1')) >=0
        AND REGEXP_LIKE(TRIM(xmlmsg.dd_days), '^-?[[:digit:],.]*$')
    PART_ID                   DD_DAYS              DT_ID
    A5556689                  10                   430
    SQL>
    SY.

  • TO_CHAR to convert date getting 'Invalid number' error

    I am trying to convert a static date value using TO_CHAR function but I can't believe I am not able to do it such a simple conversion.
    //Obviously this is easy and everyone would like to give this as an example and this is what I see everwhere on Google and it works.
    SELECT TO_CHAR(sysdate, 'YYYY-MM-DD') FROM DUAL;
    How can I make it work like this?
    SELECT TO_CHAR('2010-JUN-23', 'YYYY-MM-DD') FROM DUAL;
    I keep getting "Invalid number" error. I changed my constant date to different formats but none works.

    Your first literal is not a date, assuming you didn't set NLS_DATE_FORMAT.
    So the code should have been
    SELECT TO_CHAR(to_date('2010-JUN-23','YYYY-MON-DD'), 'YYYY-MM-DD') FROM DUAL;
    Please note DATEs are always converted to VARCHAR2 when you SELECT them, using NLS_DATE_FORMAT.
    When you use a DATE string literal it ias always implicitly converted to a real date, by using NLS_DATE_FORMAT.
    So if you want all your dates formatted as YYYY-MON-DD, you need to set NLS_DATE_FORMAT to that mask.
    Sybrand Bakker
    Senior Oracle DBA

  • Trying to complete profile - get invalid number error

    I'm attempting to complete my Skype profile, but am running into a problem when trying to enter my mobile number.  I've entered it as xxxxxxxxxx and xxx-xxx-xxxx, neither seems acceptable. The error says, "It looks like you entered an invalid number - try again, so friends will have more ways to contact you." Not sure what I'm doing wrong.  I'm in the US and am attempting to use Skype Web (beta).  Need to use this for a call on Monday.

    Your first literal is not a date, assuming you didn't set NLS_DATE_FORMAT.
    So the code should have been
    SELECT TO_CHAR(to_date('2010-JUN-23','YYYY-MON-DD'), 'YYYY-MM-DD') FROM DUAL;
    Please note DATEs are always converted to VARCHAR2 when you SELECT them, using NLS_DATE_FORMAT.
    When you use a DATE string literal it ias always implicitly converted to a real date, by using NLS_DATE_FORMAT.
    So if you want all your dates formatted as YYYY-MON-DD, you need to set NLS_DATE_FORMAT to that mask.
    Sybrand Bakker
    Senior Oracle DBA

  • Invalid number error when calculating with sysdate

    Hello - I am getting invalid number error for query below:
    SELECT *
    FROM
    trkg
    WHERE
    trkg.tran_type=500
    AND
    trkg.mod_date_time>sysdate-0.5
    I am not sure what is wrong with above query. Strange part is that it executes fine in one environmnet and returns 'invalid number' error in other environmnet? Please help me find missing setting.

    more information:
    Table1: LOCN_HDR with field locn_brcd and locn_id
    locn_brcd locn_id
    26001A 0000086
    26002A 0000087
    26001B 0000088
    Table2: PICK_LOCN with field LOCN_ID
    locn_id
    0000086
    0000087
    0000088
    Table3: TRKG with field from_locn and mod_date_time (this is timestamp field)
    from_locn mod_date_Time
    0000086 29-MAY-13 10.09.23.000000000 AM
    0000087 29-MAY-13 10.11.48.000000000 AM
    0000088 31-MAY-13 04.07.21.000000000 PM
    Now I combine Table1 and Table3
    select * from appwms.locn_hdr lh
    join
    (SELECT lh.locn_brcd,trkg.mod_Date_Time from appwms.trkg
    join appwms.locn_hdr lh
    on trkg.FROM_LOCN = lh.LOCN_ID
    where
    trkg.TRAN_TYPE = 500
    and trkg.mod_Date_time>sysdate-5
    ) trkg1 on lh.locn_brcd=trkg1.locn_brcd
    -- returns values correctly
    Now when I join another table to above (ie table 2), it returns 'invalid number'
    select * from appwms.locn_hdr lh
    join
    (SELECT lh.locn_brcd,trkg.mod_Date_Time from appwms.trkg
    join appwms.locn_hdr lh
    on trkg.FROM_LOCN = lh.LOCN_ID
    where
    trkg.TRAN_TYPE = 500
    and trkg.mod_Date_time>sysdate-5
    ) trkg1 on lh.locn_brcd=trkg1.locn_brcd
    join
    (select pld.locn_id,lh.locn_brcd
    from APPWMS.PICK_LOCN PLD join appwms.locn_hdr lh
    on pld.locn_id = lh.LOCN_ID ) picklocn on picklocn.locn_brcd=lh.locn_brcd
    why are rows returned with one join? when i have more than one join why does it return error 'invalid number'.

  • When calling to phone, I get "Invalid number" to n...

    Hi,
    I had SIM card from one mobile provider in Ireland and I have moved my number to other mobile provider. After successful transfer I am not able to call to my number (+35389xxxxxxx) from skype and I get "invalid number" error message.
    I was able to call before transfer.
    Is it skype problem or new mobile provider bad transfer problem?
    Thanks
    Solved!
    Go to Solution.

    SauLius wrote:
    Is new mobile provider bad transfer problem?
    Yes it is. Please contact your provider.
    TIME ZONE - US EASTERN. LOCATION - PHILADELPHIA, PA, USA.
    I recommend that you always run the latest Skype version: Windows & Mac
    If my advice helped to fix your issue please mark it as a solution to help others.
    Please note that I generally don't respond to unsolicited Private Messages. Thank you.

  • Getting ORA-01722 invalid number error

    what is wrong with the query throwing invalid number error
    SELECT NVL(OPT_WA_FAIR_VAL_A,0)
    FROM AUDIT_GRN ag
    WHERE ag.ORG_GRP_I = 1
    AND ag.GRN_N = 2
    AND (ag.ED_EFF_M,NVL(ag.ED_END_M,SYSDATE)) IN (SELECT MAX(ED_EFF_M),MAX(NVL(ED_END_M,SYSDATE))
    FROM AUDIT_GRN ag2
    WHERE ag2.ORG_GRP_I= ag.org_grp_i
    AND ag2.grn_n=ag.grn_n
    AND To_Date(To_Char(ag2.ED_EFF_M,'MM/DD/YYYY'),'MM/DD/YYYY') <= TO_DATE(TO_CHAR('08/04/06','MM/DD/YYYY'),'MM/DD/YYYY')
    AND To_Date(To_Char(NVL(ag2.ED_END_M,SYSDATE),'MM/DD/YYYY'),'MM/DD/YYYY') >= TO_DATE(TO_CHAR('08/04/06','MM/DD/YYYY'),'MM/DD/YYYY'));

    Error occurs at this line-excluding these line iam getting output
    Audit _grn striucture is
    org_grp_i number(6)
    grn_n number
    ed_eff_m timestamp(6)
    ed_end_m timestamp(6)
    OPT_WA_FAIR_VAL_A number(18,6)
    AND To_Date(To_Char(ag2.ED_EFF_M,'MM/DD/YYYY'),'MM/DD/YYYY') <= TO_DATE(TO_CHAR('08/04/2006','MM/DD/YYYY'),'MM/DD/YYYY')
    AND To_Date(To_Char(NVL(ag2.ED_END_M,SYSDATE),'MM/DD/YYYY'),'MM/DD/YYYY') >= TO_DATE(TO_CHAR('08/04/2006','MM/DD/YYYY'),'MM/DD/YYYY'));

  • To_number function and the "invalid number" error

    Dear all,
    I have searched the forum for threads relating to the ORA-01722: invalid number error, could not find the answer I am looking for.
    What I was trying to do was
    select * from table1 where to_number(field1) > 1000
    field1 is a varchar2 data type.
    I tried all sorts of things i.e using fmt, nls params as defined in the documentation, nothing worked.
    Though the practical problem was solved by
    select * from table1 where field1 > '1000'
    I would still like to know why this error occurs. Can someone help ?
    Regards
    Crusoe

    I think the database engine should simply return the rows that successfully convert to number and meet the where condition Oracle does not work in that way ;)
    Then try this...
    Just you need to add the below where clause to your source query. as this will retrieve only the number, to_number should work without any problem.
    But still you have to create a subquery to escape the invalid number error.
    PRAZY@11gR1> select * from tablea;
    FIELD1
    123
    123.345
    45
    AVC
    23.234.234
    ABC.234
    345.45
    7 rows selected.
    Elapsed: 00:00:00.00
    PRAZY@11gR1> select to_number(field1) from tablea where  rtrim(trim(regexp_replace(field1,'\.','',1,1)),'0123456789') is null;
    TO_NUMBER(FIELD1)
                  123
              123.345
                   45
               345.45
    4 rows selected.
    Elapsed: 00:00:00.01Regards,
    Prazy
    Edited by: Prazy on Mar 23, 2010 4:00 PM

  • Case When Statement and ORA:01722 Invalid number error

    Hi folks, I have posted this under another heading as well under E-business suite so apologies if some you have already seen it but I would really appreciate some help on this one. Any suggestions are most welcome.
    We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
    The period is always a rolling 6 months from sysdate.
    This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
    This is probably over complicated but we are not techie at all so are learning as we go!
    We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
    SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))

    Hi,
    It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
    However, your formula is far more complicated than it needs to be.
    Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
    date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
    GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
    and AbsenceEnd as
    LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
    Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
    SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
    That's it. Not so complicated after all.
    Rod West

  • Case When Statement and ORA:1722 Invalid number error

    Sorry I posted this in the wrong forum - I have the answer now
    Cheers
    HELP!!!
    We are trying to put together a calculation that returns the number of days absent an individual has had in a given time period. We need to cater for those absences that started before the period and are closed during it, absence that start during the period and end after it, and those that open and close within it.
    The period is always a rolling 6 months from sysdate.
    This is the calc we have come up with so far which works for some people but we get the invalid number error if the absence includes a half day - so 0.5, 1.5,etc.
    This is probably over complicated but we are not Techie at all so are learning as we go! We are using the HRMS - Administration - Oracle Human Resources (Core) business area in 10G and the Absence Attendance and Person folders.
    SUM(TO_NUMBER(NVL(( CASE WHEN Absence Attendance.Actual Start Date < TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') THEN ( CASE WHEN Absence Attendance."Actual End Date" > SYSDATE THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) END ) END ) ELSE ( CASE WHEN ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) END ) END ) END ) IS NULL THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),SYSDATE) ) ELSE ( CASE WHEN TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY') >= Absence Attendance.Actual Start Date THEN ( WORKING_DAYS_BETWEEN(TO_DATE(ADD_MONTHS(SYSDATE,-6),'DD-Mon-YYYY'),Absence Attendance."Actual End Date") ) ELSE ( CASE WHEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") ) IS NULL THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( CASE WHEN SYSDATE <= Absence Attendance."Actual End Date" THEN ( WORKING_DAYS_BETWEEN(Absence Attendance.Actual Start Date,SYSDATE) ) ELSE ( Absence Attendance.Duration Days ) END ) END ) END ) END ) END ),( DAYS_BETWEEN(Absence Attendance.Actual Start Date,Absence Attendance."Actual End Date") )),'999999990D00'))
    Edited by: CPearce on Sep 25, 2008 8:03 AM

    Hi,
    It could be that this is because you are using SYSDATE which contains the time as a fraction rather than TRUNC(SYSDATE) which just contains the current time. It could be that your working_dates_between raises this error.
    However, your formula is far more complicated than it needs to be.
    Firstly, you want to look at the date window ADD_MONTHS(TRUNC(SYSDATE), -6) to TRUNC(SYSDATE). Then you want to look at the portion of the absence that falls in the date window. This is GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6)) to LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE)). You may need to add 1 to the absence end date because this is the last day of their absence rather than the date they return. It depends how you calculate the days between the start and end
    date of the absence. You can create calculations for the start and end date of the absences within the 6 months time window. Create calculation AbsenceStart as
    GREATEST(Absence Attendance.Actual Start Date, ADD_MONTHS(TRUNC(SYSDATE), -6))
    and AbsenceEnd as
    LEAST(NVL(Absence Attendance."Actual End Date",TRUNC(SYSDATE)), TRUNC(SYSDATE))
    Then you need to only pick up absence that a part of the absence in your 6 month date window. You can use a condition in the workbook or a condition in a case statement to do this. You then need to calculate the difference between these dates and SUM all the values.
    SUM(CASE WHEN AbsenceEnd >= AbsenceStart THEN WORKING_DAYS_BETWEEN(AbsenceStart, AbsenceEnd) END)
    That's it. Not so complicated after all.
    Rod West

  • Recieving ORA-01722 invalid number error while creating a materialized view

    Hi,
    I am receiving a ORA-01722 invalid number error while creating a materialized view. when run the select statement of the view i don't get any error, but when i use the same select statement to create a materialized view i receive this error. Could any please help in resolving this error. Here is the code i am using to create a materialized view.
    CREATE MATERIALIZED VIEW MV_EBS_CH_CLOSED
    REFRESH FORCE ON DEMAND
    AS
    SELECT DISTINCT kr.request_id, org.org_unit_name,
    ebs_ch_ticket_type (kr.request_id) ticket_type,
    DECODE
    (kr.status_code,
    'CLOSED_SUCCESS', kr.last_update_date,
    'IN_PROGRESS', (SELECT MAX (start_time)
    FROM ebs_ch_datastore ecd1
    WHERE kr.request_id = ecd1.request_id
    AND workflow_step_name =
    'Final BA Review and Deployment Exit Criteria')
    ) closed_date,
    substr(krhd.visible_parameter12,1,10) siebel_start_date,
    kr.creation_date itg_start_date
    FROM kcrt_requests kr,
    kcrt_request_types krt,
    kcrt_req_header_details krhd, kcrt_request_details krd1,
    (SELECT koum.user_id user_id,
    DECODE (koup.org_unit_name,
    'IT Implementations', 'CHS - Service Management BA',
    koup.org_unit_name
    ) org_unit_name
    FROM krsc_org_unit_members koum, krsc_org_units koup
    WHERE 1 = 1
    AND 'Y' = koup.enabled_flag
    AND koum.org_unit_id = koup.org_unit_id
    AND EXISTS (
    SELECT 'X'
    FROM krsc_org_units kouc
    WHERE koup.org_unit_id = kouc.org_unit_id
    START WITH kouc.parent_org_unit_id =
    ANY (SELECT org_unit_id
    FROM krsc_org_units krsc_org_units1
    WHERE 'Clearinghouse' =
    org_unit_name)
    CONNECT BY kouc.parent_org_unit_id =
    PRIOR kouc.org_unit_id)
    UNION
    SELECT kou.manager_id user_id,
    DECODE
    (kou.org_unit_name,
    'IT Implementations', 'CHS - Service Management BA',
    kou.org_unit_name
    ) org_unit_name
    FROM krsc_org_units kou
    WHERE 'Y' = kou.enabled_flag
    START WITH kou.parent_org_unit_id =
    (SELECT org_unit_id
    FROM krsc_org_units krsc_org_units2
    WHERE 'Clearinghouse' = org_unit_name)
    CONNECT BY kou.parent_org_unit_id = PRIOR kou.org_unit_id) org
    WHERE krt.request_type_id = kr.request_type_id
    AND krt.request_type_name IN ('Bug Fix', 'IT Enhancement')
    and kr.REQUEST_ID = krd1.request_id
    and krd1.batch_number = 1
    AND kr.request_id = krhd.request_id
    AND org.user_id in (krd1.parameter4, krd1.parameter5, krd1.parameter7)
    AND ( 'CLOSED_SUCCESS' = kr.status_code
    OR 'IN_PROGRESS' = kr.status_code
    AND kr.request_id IN (
    SELECT request_id
    FROM (SELECT DISTINCT request_id,
    MAX
    (start_time)
    closed_date
    FROM ebs_ch_datastore
    WHERE 'Final BA Review and Deployment Exit Criteria' =
    workflow_step_name
    GROUP BY request_id))
    Thanks,
    Shaik Mohiuddin

    This error occurs when you try to create a materialized view , but if you run the sql the results are perfectly fine. Well it happend to me also and to fix this I made sure all the coulmns have the same data type which are used in joins or in where clause.
    use
    where
    to_number(col1)=to_number(col2) and to_number(col3)=to_number(col4)
    hope this helps..

  • Another ORA-01722: invalid number Error

    Hello All,
    I have 2 Validations on 1 Item, Not Null and Not Exists, very standard.
    select fk_session_name_id
    from hrt_session
    where fk_session_name_id = :p9_fk_session_name_id
      and fk_class_id = :p9_fk_class_id;My Item needs to be a Select List that returns the ID of FK_SESSION_NAME_ID.
    select distinct SESSION_NAME display_value, PK_SESSION_NAME_ID return_value
    from HRT_SESSION_NAME
    order by 1My Form Page throws the ORA-01722 in invalid number Error only when I make the Item a Select List. If Item is a
    Text Field and ID value entered and Create is clicked the data is saved but not when its a Select List. I have read alot
    of threads that talk about converting this Item to_number but I have not been successful in doing this. Once the Item is
    a Select List the Not Exists validation works but the Not Null Validation populates the Error Message. Can anyone
    assist me with this please? Thanks
    My Data Type is INTEGER for FK_SESSION_NAME_ID and SESSION_NAME is VARCHAR2.
    SESSION_NAME data....
    SESSION 1
    SESSION 2
    PMAS 1
    PMAS 2
    BASIC WORD 2003.....
    Edited by: Charles A on Jan 11, 2010 1:42 PM

    Hey Jari,
    The PK_SESSION_NAME_ID in the select statement is the value that is going to be returned. FK_SESSION_NAME_ID is the Foreign Key value that will get the value from the Primary Key PK_SESSION_NAME_ID.
    Yes, I do have an account that you can log into, thanks for assistance Jari.
    Once you log in Select link 'Hrt_Class' which will populate Page 2. Region 'Cascading LOVs has 4 Items. Class Meridiem, Class Name, Class End Date and Class Location. Select these values then click 'Search'. Once the values are populated click the red button at the bottom 'Add Session Info'. This will populate Page 9 which will allow you to test the Create button. You should not be able to add any Session Name that exists in the Report below and you should not be able to Create a Null FK_SESSION_NAME_ID. Let me know if this is clear, thanks again.
    The PK_SESSION_ID cannot be Null so just start with values 60116 on up to avoid that error message. I do not have any sequences or triggers created since this is just a testing app.
    Edited by: Charles A on Jan 11, 2010 4:05 PM

  • Invalid number error , number column as last field in my csv

    LOAD DATA
    INFILE 'test.csv' "str '#'"
    APPEND
    INTO TABLE esgapp.c_test
    FIELDS TERMINATED BY "," Optionally enclosed by '"'
    TRAILING NULLCOLS
    rstring,
    rtext char(12000) ENCLOSED BY '<start>' and '<end>',
    ruser,
    rid SEQUENCE(MAX,1)
    This control file is working good . But what i have done is i have altered my table *ruser* column which was earlier varchar now it is number . the data in the ruser is number , now i am getting an error while executing the the script
    it is throwing an invalid number error .
    i have tried this changes before i post this post in the control file but all are throwing the invalid number error
    ruser char "to_number(rtrim(ltrim(:ruser)))"
    and
    ruser decimal external
    csv file
    hello,<start>bla...bla...bla...bla,-996203
    error
    invalid number
    Edited by: user7955917 on Mar 5, 2012 9:34 AM
    Edited by: user7955917 on Mar 5, 2012 9:41 AM
    Edited by: user7955917 on Mar 5, 2012 9:42 AM

    But....If your Oracle version is 10g+, you can define the file as external table and use the "RECORDS DELIMITED BY '#'" parameter.
    :p

  • Invalid number error for bind dialog

    Oracle SQL Developer version 1.1.2.25 BUILD MAIN-25.79
    Running under WinXP
    Issue description:
    We get an invalid number error when bind variable filled with an enter in the bind dialog

    It is hard to say what is causing your problem without the specifics (ie query and value entered for the bind variable). Try running the same statement with the value of the bind variable in place of the bind variable (ie instead of running "select * from dual where dummy = :var" with a value of 'x' for :var, run "select * from dual where dummy = 'x'"). If you get the same error, then it is not an issue with the use of bind variables.
    Be aware that currently you cannot define the data type of bind variables (unlike TOAD, etc) and they are all treated as character values. I wouldn't have thought that this would cause you problem unless you are using a bind variable to restrict a numeric column to a specific value and you are entering a non-numeric bind (ie "select * from people where person_id = :id" and using 'xyz' as the value for :id).

  • ORA-01722: invalid number error. In Update

    create or replace procedure San_Test (sInNum varchar2, outMsg out varchar2)
    is
    begin
    update mtest set
    mname = 'Success'
    where id in (sInNum);
    commit;
    outMsg :='Success';
    exception
    when others then
    outMsg :='Err';
    dbms_output.put_line(sqlerrm);
    end;
    This is my test sp where i am getting ORA-01722: invalid number error.
    Which is because the column data type is Number of ID and i have sInNum parameter as varchar2.. How can i achieve this ?
    I don't have other way to do this please help.

    Great demonstration for SQL INJECTION, was that part of your OCP training?
    CREATE TABLE mtest (id NUMBER, mname VARCHAR2(255));
    INSERT INTO mtest VALUES (1, 'test');
    INSERT INTO mtest VALUES (2, 'test2');
    COMMIT;
    CREATE OR REPLACE PROCEDURE san_test (sinnum VARCHAR2, outmsg OUT VARCHAR2)
    IS
       mnum     VARCHAR2 (10);
       strsql   VARCHAR2 (250);
    BEGIN
       mnum := REPLACE (sinnum, '''', '');
       strsql :=
           'update mtest set
    mname = ''Success''
    where id in (' || mnum || ')';
       EXECUTE IMMEDIATE strsql;
       COMMIT;
       outmsg := 'Success';
    EXCEPTION
       WHEN OTHERS
       THEN
          outmsg := 'Err';
          DBMS_OUTPUT.put_line (SQLERRM);
    END;
    SELECT *
      FROM mtest;
            ID MNAME
             1 test
             2 test2And now for the fun part:
    SET SERVEROUTPUT ON
    DECLARE 
      v_put_msg VARCHAR2(255);
    BEGIN
      san_test('1) OR (1=1', v_put_msg);
      dbms_output.put_line(v_put_msg);
      COMMIT;
    END;
    SELECT *
      FROM mtest;
            ID MNAME
             1 Success
             2 SuccessC.

Maybe you are looking for

  • IPad, component video, and movies in HD?

    I have an iPad 2 that I connect to my TV with a component video breakout--I know that an HDMI breakout is available, but I originally bought the component breakout to use with an iPod Classic and, well, it works with the iPad 2. When I connect the iP

  • Half of my screen is blank

    half of my screen is blank, and its not under warranty anymore. does anyone no how 2 fix it, or should i just get a new 1   Mac OS 9.2.x  

  • Using VoIP and can not send or receive fax. I am now also having problem scanning

    I use VoIP for phone service. I can not send or receive faxes although the Fax Test Report Pass. Now I am having problem scanning. My main concern is with faxing.

  • Can we report on BW table using BW query

    Hello All, I want to know if we can create a DSO on top of a table created in BW system (NOT ECC system). In this case can we do a DSO with table as a data source or something similar to that. There are no Key figures. Actually the scenario is if we

  • Scheduling in Discoverer 10g

    Hi, We are currently running Discoverer 10g plus. Is it possible to increment the parameters on the schedule similar to Oracle requests that give the option to 'Increment date parameters each run'? Thanks, Steve