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

Similar Messages

  • How do I TRULY remove the CRLF (#) from the last field read in CSV dataset?

    Good day, everyone!
    PLEASE NOTE:  I spent most of yesterday searching SDN and reading all kinds of threads on this topic.  Yes, I know, there ARE other threads out there regarding this topic, but I spent all of yesterday afternoon trying every solution posted and nothing worked.  So, to my knowledge, nobody has yet to post a definite solution to this problem.
    I am reading a comma-delimited CSV file from our Application Server.  It was originally in Microsoft Excel but saved as a CSV file.  I open the file as follows:
    OPEN DATASET p_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    Here is my loop to read the entire file into an internal table, splitting it into individual fields:
      READ DATASET p_fname INTO wa_unsplit.
      WHILE sy-subrc EQ 0.
        ADD 1 TO w_unsplit_tot.
        SPLIT wa_unsplit AT w_comma INTO:
              wa_split-massn
              wa_split-massg
              wa_split-curr
              wa_split-persg
              wa_split-pernr
              wa_split-persid
              wa_split-persk
              wa_split-stat2
              wa_split-fisc_year
              wa_split-funds_center
              wa_split-plans
              wa_split-orgeh
              wa_split-abkrs
              wa_split-werks
              wa_split-sem_posit
              wa_split-ansal
              wa_split-bsgrd
              wa_split-adm_adj_amt
              wa_split-hourly_rate.
        APPEND wa_split TO it_split.
        CLEAR: wa_unsplit,
               wa_split.
        READ DATASET p_fname INTO wa_unsplit.
      ENDWHILE.
    The problem is that the last field, wa_split-hourly_rate (defined as character length 17) gets a '#' appended to the end of it.  This happens with each record, and it appears to be the CR/LF character (the value of it in hex is the same as cl_abap_char_utilities=>cr_lf).
    I've tried everything previously recommended to strip this character from my hourly_rate field.  I've tried another STRIP command.  I've tried REPLACE and TRANSLATE and a whole slew of things.  Despite all the threads that exist on SDN about this, I've yet to find something that truly works.
    Certainly I can't be the first person reading a file from the Application Server and having this issue.
    Please do NOT post links to solutions that DO NOT WORK!  Full points will be awarded to anyone who can solve this challenge.
    Thanks everyone!

    Success!  Peluka and Naimesh, I had to combine your two recommendations, and I finally got it to work!
    Thanks for the clarification, Rich.  I ended up calling my "aux" field "junk" for lack of a better word, but in the end you confirmed what I thought it was.
    For anyone else out there who has struggled finding a successful answer to this challenge, here's what worked for me:
    CONSTANTS: c_comma(1)  TYPE c VALUE ',',
               c_crlf(1)   TYPE c VALUE cl_abap_char_utilities=>cr_lf.
    DATA: w_junk          TYPE string.
      READ DATASET p_fname INTO wa_unsplit.
      WHILE sy-subrc EQ 0.
        ADD 1 TO w_unsplit_tot.
        SPLIT wa_unsplit AT c_comma INTO:
              wa_split-massn
              wa_split-massg
              wa_split-curr
              wa_split-persg
              wa_split-pernr
              wa_split-persid
              wa_split-persk
              wa_split-stat2
              wa_split-fisc_year
              wa_split-funds_center
              wa_split-plans
              wa_split-orgeh
              wa_split-abkrs
              wa_split-werks
              wa_split-sem_posit
              wa_split-ansal
              wa_split-bsgrd
              wa_split-adm_adj_amt
              wa_split-hourly_rate.
    And here is the line that removes the CR/LF character from the end of the Hourly Rate field!
        SPLIT wa_split-hourly_rate AT c_crlf INTO:
        wa_split-hourly_rate w_junk.
        APPEND wa_split TO it_split.
        CLEAR: wa_unsplit,
               wa_split.
        READ DATASET p_fname INTO wa_unsplit.
      ENDWHILE.
    Thanks so much, everyone!  Once again, SDN folks save the day.  Points awarded!

  • Unknown column 'NewMessages' in 'field list'

    Hi,
    I am using PHP MySQL.
    Ok, I am pretty sure my Hosting service upgraded either phpmyadmin, php, mysql, or all three because they are slightly different than before. So this code:
    $colname_NewMessages = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_NewMessages = $_SESSION['MM_Username'];
    mysql_select_db($database_ProfileID, $ProfileID);
    $query_NewMessages = sprintf("SELECT * FROM Message_System WHERE Reciever = %s AND Status = 'Not_Read' ", GetSQLValueString($colname_NewMessages, "text"));
    $NewMessages = mysql_query($query_NewMessages, $ProfileID) or die(mysql_error());
    $row_NewMessages = mysql_fetch_assoc($NewMessages);
    $totalRows_NewMessages = mysql_num_rows($NewMessages);
    use to work fine, but now it is returning the error "Unknown column 'NewMessages' in 'field list'"!
    Can anyone help me with this?
    Thanks

    Use echo to see the actual query that's being sent to the database:
    $colname_NewMessages = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_NewMessages = $_SESSION['MM_Username'];
    mysql_select_db($database_ProfileID, $ProfileID);
    $query_NewMessages = sprintf("SELECT * FROM Message_System
                                  WHERE Reciever = %s
                                  AND Status = 'Not_Read' ",
           GetSQLValueString($colname_NewMessages, "text"));
    echo $query_NewMessages;
    exit;
    $NewMessages = mysql_query($query_NewMessages, $ProfileID) or die(mysql_error());
    $row_NewMessages = mysql_fetch_assoc($NewMessages);
    $totalRows_NewMessages = mysql_num_rows($NewMessages);

  • Invalid Number Error for Decimal Field While Loading Data

    I am loading a delimited text file using the SQL* loader however I am reciving an error in my decimal fields. When a decimal field only has leading zeros before the decimal point I receive invalid number error. Below will clarify:
    i.e.) 00000000.30 [*Invalid number*]
    i.e.) 00046567.45 [*Valid number*]
    i.e.) 00000001.00 [*Valid number*]
    I've tried setting the precision/scale in the table, tried declaring it a decimal field instead of number, none of these methods fixed the issue. Any help I would really appreciate.
      POLICY_NUMBER             NUMBER,
      EFFECTIVE_DATE     DATE "YYYYMMDD"          NULLIF EFFECTIVE_DATE = '',
      TRANSACTION_DATE     DATE "YYYYMMDD",
      TRANSACTION_AMOUNT     DECIMAL EXTERNAL,   -- Tried TRANSACTION_AMOUNT DECIMAL EXTERNAL (10)  & TRANSACTION_AMOUNT NUMBER
      MF_TRX_CODE          NUMBER,
      USER_ID          CHAR,
      GROUP_NUMBER          NUMBER,
      EXPIRATION_DATE     DATE "YYYYMMDD"          NULLIF EXPIRATION_DATE = '',
      BILL_NUMBER          NUMBER,Any help is greatly appreciated. Thanks before hand.

    Hi,
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> SELECT * FROM TEST;
    TRANSACTION_AMOUNT
    SQL> SELECT * FROM TEST;
    TRANSACTION_AMOUNT
              11000,00
                293,37
               2000,00
               1134,32
                  0,30
    SQL>Between the selects I loaded the table with sql*loader using...
    Load Data
    INFILE *
    APPEND
    INTO TABLE TEST
    FIELDS TERMINATED BY '|'
    TRAILING NULLCOLS
      TRANSACTION_AMOUNT     DECIMAL EXTERNAL
    BEGINDATA
    00011000.00
    00000293.37
    00002000.00
    00001134.32
    00000000.30The log is
    SQL*Loader: Release 10.2.0.1.0 - Production on Tue Dec 23 17:23:47 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Control File:   test.ctl
    Data File:      test.ctl
      Bad File:     test.bad
      Discard File:  none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array:     64 rows, maximum of 256000 bytes
    Continuation:    none specified
    Path used:      Conventional
    Table TEST, loaded from every logical record.
    Insert option in effect for this table: APPEND
    TRAILING NULLCOLS option in effect
       Column Name                  Position   Len  Term Encl Datatype
    TRANSACTION_AMOUNT                  FIRST     *   |       CHARACTER           
    Table TEST:
      5 Rows successfully loaded.
      0 Rows not loaded due to data errors.
      0 Rows not loaded because all WHEN clauses were failed.
      0 Rows not loaded because all fields were null.
    Space allocated for bind array:                  16512 bytes(64 rows)
    Read   buffer bytes: 1048576
    Total logical records skipped:          0
    Total logical records read:             5
    Total logical records rejected:         0
    Total logical records discarded:        0
    Run began on Tue Dec 23 17:23:47 2008
    Run ended on Tue Dec 23 17:23:50 2008
    Elapsed time was:     00:00:02.86
    CPU time was:         00:00:00.06Regards,

  • How to determine offending column in ORA-01722: invalid number error ...

    When an error like
    ORA-01722: invalid number error
    occurs and you are dealing with many columns that could be the 'culprit', does anyone have a method by which
    you can quickly determine offending column?

    SQL PLus will tell you:
    SQL> create table t
      2  (col1  number
      3  ,col2  number
      4  ,col3  number
      5  ,col4  number
      6  ,col5  number
      7  );
    Table created.
    SQL> create table x
      2  (col1  varchar2(10)
      3  ,col2  varchar2(10)
      4  ,col3  varchar2(10)
      5  ,col4  varchar2(10)
      6  ,col5  varchar2(10)
      7  );
    Table created.
    SQL> insert into x values ('1','2','x','4','5');
    1 row created.
    SQL> insert into t(col1,col2,col3,col4,col5)
      2  select col1,col2,col3,col4,col5 from x;
    select col1,col2,col3,col4,col5 from x
    ERROR at line 2:
    ORA-01722: invalid numberAnd if you rearrange your sql like this, sql plus will give you the line number of the offending column:
    SQL> insert into t
      2  (col1
      3  ,col2
      4  ,col3
      5  ,col4
      6  ,col5
      7  )
      8  select col1
      9        ,col2
    10        ,col3
    11        ,col4
    12        ,col5
    13  from x;
          ,col3
    ERROR at line 10:
    ORA-01722: invalid number

  • ORA-01722: invalid number error - column data type is date

    Hi all,
    When I perform this statement everything is ok, but some of clientbirthday values are null:
    select d.id, d.name, d.contragenttypeid, d.reestrtypeid, d.clientbirthday
    from creator.contragent d
    where d.contragenttypeid = 3
      and d.reestrtypeid in (2,4) When I'm trying to get "d.clientbirthday is not null" I receive error:
    select d.id, d.name, d.contragenttypeid, d.reestrtypeid, d.clientbirthday
    from creator.contragent d
    where d.contragenttypeid = 3
      and d.reestrtypeid in (2,4)
      and d.clientbirthday is not null ORA-01722: invalid number
    What is wrong? Why does it say "number" when clientbirthday column datatype is date ?

    Can you make a desc creator.contragent

  • Find the Column Name which gives Invalid Number Error

    Hi,
    There are about 150 columns in a table and data to this table is from a external source like flat file. when these data are loaded to the table for a particular column it gives Invalid Number Error. So need to find for Which Numeric Column a String Value is about to be inserted.
    since we are sure not whether the proper Values are coming from Source in Front End we pass the Value within ' quotes.
    So how do we get the Column for which the error is raised :-)

    If you are using SQL*Loader, the log will tell you which row and column has the error.
    Otherwise you may need to code your own debugging statements.

  • ORA-01722: invalid number error with Bulk collect

    Hi ,
    I have been using the script to delete old seasonal data from my application DB tables. The stored procedure has been created successfully but when i try to run the proc it has been throwing 'ORA-01722: invalid number' exception at line 'FETCH C1_CUR BULK COLLECT INTO C1_TYPE_VAR LIMIT v_bulklimit;'.
    Could you please help me here?
    Below is the stored proc:
    CREATE OR REPLACE PROCEDURE clean_old_season_data(P_SEASON VARCHAR2) AS
    CURSOR C1_CUR IS SELECT ROWID RID,pro.* FROM PROPS pro where pro.ITEMPK IN
    (SELECT sve.pk FROM SAVEDVALUEENTRY sve WHERE sve.p_parent IN
    (SELECT s.pk FROM SAVEDVALUES s WHERE s.P_MODIFIEDITEM IN
    (SELECT a.PK
    FROM products a
    WHERE a.p_season IN (select s.pk from Seasons s where s.P_code=P_SEASON)
    ) ) ) and rownum<5;
    CURSOR C2_DEL IS SELECT RID FROM PROPS_HISTORY;
    TYPE C1_TYPE IS TABLE OF C1_CUR%ROWTYPE;
    C1_TYPE_VAR C1_TYPE;
    TYPE C2_TYPE IS TABLE OF UROWID;
    C2_TYPE_VAR C2_TYPE;
    ex_dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(ex_dml_errors, -24381);
    l_error_count NUMBER;
    err_num NUMBER;
    err_msg VARCHAR2 (300);
    COMMIT_VARIABLE PLS_INTEGER:=0;
    v_bulklimit NUMBER:=2;
    BEGIN
    /*------------------ Data Selection and INSERTION IN HISTORY TABLE ---------------------------------------*/
    OPEN C1_CUR;
    LOOP
    DBMS_OUTPUT.put_line('Cursor opend now in loop');
    FETCH C1_CUR BULK COLLECT INTO C1_TYPE_VAR LIMIT v_bulklimit;//ERROR OCCURS HERE
    DBMS_OUTPUT.put_line('Cursor count is'|| C1_TYPE_VAR.COUNT);
    FORALL I IN 1..C1_TYPE_VAR.COUNT SAVE EXCEPTIONS
    INSERT INTO PROPS_HISTORY VALUES C1_TYPE_VAR(I);
    COMMIT_VARIABLE := COMMIT_VARIABLE + v_bulklimit;
    DBMS_OUTPUT.put_line('Commit variable'|| COMMIT_VARIABLE.COUNT);
    IF COMMIT_VARIABLE = v_bulklimit THEN
    COMMIT;
    COMMIT_VARIABLE := 0;
    END IF;
    EXIT WHEN C1_CUR%NOTFOUND;
    END LOOP;
    DBMS_OUTPUT.put_line('Cursor closed now in loop and data inserted in history table');
    CLOSE C1_CUR;
    /*------------------ Data Selection and DELETION IN Live TABLE ---------------------------------------*/
    COMMIT_VARIABLE := 0;
    OPEN C2_DEL;
    LOOP
    FETCH C2_DEL BULK COLLECT INTO C2_TYPE_VAR LIMIT 2;
    FORALL I IN 1..C2_TYPE_VAR.COUNT SAVE EXCEPTIONS
    DELETE FROM PROPS WHERE ROWID = C2_TYPE_VAR(I);
    COMMIT_VARIABLE := COMMIT_VARIABLE + 2;
    IF COMMIT_VARIABLE = 2 THEN
    COMMIT;
    COMMIT_VARIABLE := 0;
    END IF;
    EXIT WHEN C2_DEL%NOTFOUND;
    END LOOP;
    CLOSE C2_DEL;
    END;

    Although there are many things which should not have been done in the posted code, I could not find any reason why the Invalid number error should occur at the Fetch clause.
    I would suggest you to Insert into Table by providing the Order of Columns i.e. Insert into table (col1, ... colN) values (coll(i).col1...col(i).colN);
    I tested below code and it did not give any errors.
    drop table test_table;
    create table test_Table
      rid   varchar2(100),
      emp_id  number(5),
      fname   varchar2(20),
      lname   varchar2(50)
    set serveroutput on;
    declare
      cursor c_cur is
          select rowid rid, e.*
            from employees e
           where rownum < 10;
      type typ_cur is table of c_cur%rowtype;
      typ typ_cur;
      l_bulk_limit    number := 5;
    begin
      open c_cur;
      loop
        fetch c_cur bulk collect into typ limit l_bulk_limit;
        dbms_output.put_line('Collection Count :: ' || typ.count);
        forall i in 1..typ.count --typ.first..typ.last
          insert into test_Table (rid, emp_id, fname, lname) values (typ(i).rid,typ(i).employee_id,typ(i).first_name,typ(i).last_name);
        dbms_output.put_line('Processed ' || l_bulk_limit || ' records.');
        exit when c_cur%notfound;
      end loop;
      commit;
    end;
    select * from test_table;PS:- 1. When you are processing only 4 Records, then why are you breaking them in 2 Loops?
    2. Why Commit every time you are processing a DML? Why not maintain an Error Flag and Rollback the Transaction as soon as error is encountered?
    3. Use "{code}" (Exclude Double Quotes) to format the code. I am not sure if works.
    Regards,
    P.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Invalid number error when using external table

    Hello.
    I have a problem with creating an external table with number field.
    My txt file looks like:
    11111|text text|03718
    22222|text text text|04208
    33333|text|04215
    I try to create external table like:
    create table table_ex (
    id varchar2(5),
    name varchar2(100),
    old_id number(5))
    organization external (Type oracle_loader default directory dir
    access parameters(
    RECORDS DELIMITED BY NEWLINE
    fields terminated by '|'
    (id, name, old_id))
    location ('file.txt'));
    When i create the table and run select i get this in log file:
    Field Definitions for table TABLE_EX
    Record format DELIMITED BY NEWLINE
    Data in file has same endianness as the platform
    Rows with all null fields are accepted
    Fields in Data Source:
    ID CHAR (255)
    Terminated by "|"
    Trim whitespace same as SQL Loader
    NAME CHAR (255)
    Terminated by "|"
    Trim whitespace same as SQL Loader
    OLD_ID CHAR (255)
    Terminated by "|"
    Trim whitespace same as SQL Loader
    error processing column OLD_ID in row 1 for datafile
    /dir/file.txt
    ORA-01722: invalid number
    Whats the problem?
    Any idea?
    Thanks
    Message was edited by:
    DejanH

    Try this:
    create table table_ex
    id varchar2(5),
    name varchar2(100),
    old_id number
    organization external
    (Type oracle_loader default directory dir access parameters
    ( RECORDS DELIMITED BY NEWLINE fields terminated by '|'
    (id CHAR(5),
    name CHAR(100),
    old_id CHAR(5)
    location ('file.txt')
    I have removed the length of Number field and added length in characters later
    Aalap Sharma :)
    Message was edited by:
    Aalap Sharma

  • Invalid number error with Form on table page

    We used the "Form on Table..." wizard to create a simple page to update the SCOTT.EMP table. When we submit the page we get the ORA-01722: invalid number error. When I view the data in the WWV_FLOW_DATA view in the FLOWS_010500 schema, I can see all the data from our form in long format with the actual values that were submitted. But I can not track down where this error is coming from.

    James,
    What data did you enter in each field? Could it be as simple as you tried to enter character data into the deptno column?
    Sergio

  • 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

  • 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).

  • Please help: Case Statement - ORA-01722: invalid number Error

    Hi All,
    I'm trying to use Case statement to recode Cancelled statuses into two groups
    'Reject' if the difference between first date and last date is less than 29 and
    'Accept' if the difference between first date and last date is greater than 30
    Here is my 'test' data:
    STATUS     FIRST_DATE     LAST_DATE
    Transfer     10/08/2011     10/09/2011
    Mover     10/08/2011     15/09/2011
    Cancel     10/08/2011     16/09/2011
    Cancel     10/08/2011     5/09/2011
    Here is the syntax
    select a.*,
    (CASE WHEN a.STATUS ='Cancel' THEN (round(a.LAST_DATE-a.FIRST_DATE))
    ELSE 0
    END) CAN_DAYS,
    (CASE WHEN 'CAN_DAYS' >29 THEN 'Reject'
    WHEN 'CAN_DAYS' <30 THEN 'Accept'
    END) Reject_Accept
    from test a
    The first CASE statement works fine and gives me this
    STATUS     FIRST_DATE     LAST_DATE     CAN_DAYS
    Transfer     10/08/2011     10/09/2011     0
    Mover     10/08/2011     15/09/2011     0
    Cancel     10/08/2011     16/09/2011     37
    Cancel     10/08/2011     5/09/2011     26
    but the second CASE produces ORA-01722: invalid number Error. It is something to do with the CAN_DAYS data type, Oracle doesn't see it as Numeric i think.
    The result i want to see would be
    STATUS     FIRST_DATE     LAST_DATE     CAN_DAYS Reject_Accept
    Transfer     10/08/2011     10/09/2011     0
    Mover     10/08/2011     15/09/2011     0
    Cancel     10/08/2011     16/09/2011     37 Accept
    Cancel     10/08/2011     5/09/2011     26 Reject
    Could someone please help me to fix the syntax?
    Thank you in advance,

    This seems to give you your desired results...
    with test as
      ( select 'Transfer' as status, to_date('10/08/2011') as first_date, to_date('10/09/2011') as last_date  from dual union all
        select 'Mover'             , to_date('10/08/2011')              , to_date('15/09/2011')               from dual union all
        select 'Cancel'            , to_date('10/08/2011')              , to_date('16/09/2011')               from dual union all
        select 'Cancel'            , to_date('10/08/2011')              , to_date('05/09/2011')               from dual
    select  status
         ,  first_date
         ,  last_date
         ,  CAN_DAYS
         ,  CASE
              WHEN CAN_DAYS =   0 THEN NULL
              WHEN CAN_DAYS <  30 THEN 'Reject'
              WHEN CAN_DAYS >= 30 THEN 'Accept'
            END  Reject_Accept
      from  ( select  status
                   ,  first_date
                   ,  last_date
                   ,  CASE
                        WHEN STATUS ='Cancel' THEN round(LAST_DATE-FIRST_DATE)
                        ELSE 0
                      END  CAN_DAYS
                from  test
    ;

  • User Accounts and ORA-01722: invalid number error

    Hello,
    I have been using Express for a month or so now but have very limited knowledge of how it works.
    My Problem:
    I have a listing screen for user records which creates records in table QAS_USERS.
    When I add a record it saves the data OK and put the record in the list.
    When I click on the record in the list it takes me to the edit screen and I can change
    the details and it works OK and all the changes get saved to the database.
    On the data entry screen I have a list of the User Groups so I can select what group
    the user will be in, usual details in username, fullname, email address, password etc..
    I then added a routine to create a USER in the APEX Manage USERs.
    It creates the record in my table QAS_USERS and it creates a APEX User Account with
    the correct details and the record is displayed in the list.
    So far so good.
    Now the errors start:
    1. When I look at the User Account in Administration -> Manage Application Express Users
    most of the details have been added but the User Group does not get allocated.
    2. The record I created in QAS_USERS appears in the list on my listing screen but when
    I click on the Edit Icon on the left of the list I get the following error appear
    when the screen changes to the edit screen:
    ORA-01722: invalid number
    Unable to fetch row error
    QAS_USER Table:
    ID NUMBER
    CREATED_ON DATE
    CREATED_BY VARCHAR2(10)
    CHANGED_ON DATE
    CHANGED_BY VARCHAR2(10)
    ACTIVE VARCHAR2(3)
    USERNAME VARCHAR2(10)
    FULLNAME VARCHAR2(30)
    TEAMLEADER VARCHAR2(3)
    TEAMLEADER_ID NUMBER
    LAB NUMBER
    DIRECTOR VARCHAR2(3)
    ACTION_MANAGER VARCHAR2(3)
    SDM VARCHAR2(3)
    GM VARCHAR2(3)
    EMAIL_ADDRESS VARCHAR2(50)
    PASSWORD VARCHAR2(12)
    SDTL VARCHAR2(3)
    FIRSTNAME VARCHAR2(30)
    LASTNAME VARCHAR2(30)
    GROUP_ID NUMBER
    USER_ID VARCHAR2(20)
    Process Script to create the Express User Account:
    Declare
    group_id NUMBER;
    BEGIN
    group_id := APEX_UTIL.get_group_id (:P15_GROUP_ID);
    APEX_UTIL.CREATE_USER (
    P_USER_NAME => :P15_USERNAME,
    P_FIRST_NAME => :P15_FIRSTNAME,
    P_LAST_NAME => :P15_LASTNAME,
    P_WEB_PASSWORD => :P15_PASSWORD,
    P_EMAIL_ADDRESS => :P15_EMAIL_ADDRESS,
    p_developer_privs => 'ADMIN',
    p_group_ids => group_id);
    END;
    If any one has any ideas I would be very grateful.
    Regards,
    Simon.

    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

Maybe you are looking for

  • OfficeJet Pro 8600 and OfficeJet Pro 8630 Tray 2 missing

    Hi All, Today we have released the software patch for Tray 2 missing for Officejet 8600 and Officejet 8630 all in one printer Go to www.hp.com>> Click on Support>> Download drivers Type in your product model no Eg Officejet 8600, Officejet 8630......

  • Dynamic lookup using UDDI inside of BPEL

    Currently I'm looking into using UDDI as a solution to finding web services for BPEL, as opposed to simply keeping static WSDLs around. Initially I would just like to know if it is possible to do a lookup to a UDDI server inside of BPEL, and then inv

  • Customer check  fields

    Hello, is  this possible  by standard  or  exit needed: In case the payment condition is direct debit, it is MANDATORY that Customer Service inform about bank details. If not, the customer cannot be created. Thanks in a dvance L

  • Problem in sun web server : user-mapped section open

    Hi Friends, I am using sun web server7.0. When i am trying to update the struts-config.xml file through my application. I got the following error message. The Struts-ConfigXML couldn't be Modified Reason: C:\Program Files\SunWebServer7\https-java1.to

  • My mind escapes me...

    Ok, classify this in the newbie section... but something may just be wrong... I have FCP 5.14 When I have my viewer and browser up and I open a portion of my movie in the viewer my browser does not show the effects tab. Thus I can not add any transit