URGENT :::: Prepared Statement : Invalid Conversion Error

Hi,
I have prepared statement to update a database record. It is working fine but sometime it throws follow. SQLException. I checked the data I'm passing to the prepared statement. Everything works fine on the desktop but sometime it throws the foolow. exception on the websphere server.
Error = SQL ERROR -99999 [IBM][CLI Driver] CLI0102E Invalid conversion. SQLSTATE=07006 In Method = performBulkOperation Of Class = com.bbh.actionworld.bulksql.BulkProcessing
Its an urgent problem. Could you please help me ?
thanks in advance.

Hi
I am using a prepared statement to insert records into an RDBMS. I am using JDK 1.4.1. I use setTime to set the date fields.
My statement is
pstmtAddFC.setTime(15, Time.valueOf("00:00:00"),
Funcs.getCalendar(mydate));
Where getCalendar sets the calandar to the date specified in mydate.
I am using the JDBC:ODBC driver to connect to the database.
This works fine with Oracle but gives
java.SQL.Exception: [IBM][CLI Driver] CLI0102E Invalid Conversion. SQL STATE =07006
Any suggestions? Thanks
Regards
Lakshmi

Similar Messages

  • Urgent: Prepared Statement

    Hi Friends,
    I am doing update using Prepared statement. I have one date field in where clause. And the value of date field is null. e.g. where clr_dte is null.
    In my code I'm using ps.setNull(1, Types.DATE);
    But it is not working. I'm getting null resultset back.
    Can anybody tell me what am i doing wrong ?
    I would appreciate your help.
    Thanks in advance.
    -Priya

    Here is my query statement & below that my prepare statement. Please see the bold part.
    Thanks.
    update tnr134_pyb_rcv_shr "           +
                                                                                                   "set      updt_tsp                = ? "      +
                                                                                                   ",          updt_usr_id               = ? "      +
                                                                                                   ",          bulk_req_id               = ? "      +
                                                                                                   "where     ANNC_SMRY_ID          = ? "     +      
                                                                                                   "and     BBH_SECR_NUM          = ? "     +          
                                                                                                   "and     BBH_SECR_CRT_TSP     = ? "     +
                                                                                                   "and     CLNT_ACCT_NUM          = ? "     +      
                                                                                                   "and     CLNT_CKDGT_NUM          = ? "     +      
                                                                                                   "and     CLNT_SFX_CDE          = ? "     +
                                                                                                   "and     CLNT_PRFX_CDE          = ? "     +      
                                                                                                   "and     SOD_ACCT_NUM          = ? "     +
                                                                                                   "and     SOD_CKDGT_NUM          = ? "     +      
                                                                                                   "and     SOD_SFX_CDE               = ? "     +
                                                                                                   "and     SOD_PRFX_CDE          = ? "     +
                                                                                                   "and      REG_CDE                    = ? "     +
                                                                                                   "and     PY_PREF_NUM               = ? "     +
                                                                                                   "and     POSN_STAT_CDE          = ? "     +
                                                                                                   "and     PY_PREF_ITEM_NUM     = ? "     +
                                                                                                   "and     PY_SEQ_NUM               = ? "     +
                                                                                                   "and     PYB_RCV_CDE               = ? "     +
                                                                                                   "and     CLR_DTE                    = ? "     +
                                                                                                   "and     STLMT_DTE               = ? "     +
                                                                                                   "and     ACRL_DTE               = ? "     +
                                                                                                   "and     py_seq_item_num          = ? "     +
                                                                                                   "and      updt_tsp               <= ? "     +
                                                                                                   "and     curr_state_cde in      (select     oper_subsys__st_id "          +
                                                                                                                                      "from     tnr113_st_to_stat "               +
                                                                                                                                      "where     dsply_txt          = 'Open' "     +
                                                                                                                                      "and     dsply_typ_cde     = 'PAY' "     +
                                                                                                                                      "and     oper_subsys_id     = 5)";
    Prepared statement
    argPs.setTimestamp     (1,          argUpdateTsp);                                                                 // updt_tsp
         argPs.setString          (2,          getUserId());                                                                 // updt_usr_id
         argPs.setString          (3,          getBulkRequestId());                                                       // bulk_req_id
         argPs.setInt          (4,          Integer.valueOf(argVariables[8]).intValue());                         // annc_smry_id
         argPs.setString          (5,          argVariables[2]);                                                            // bbh_secr_num
         argPs.setTimestamp     (6,          java.sql.Timestamp.valueOf(argVariables[9]));                         // bbh_secr_crt_tsp
         argPs.setBigDecimal     (7,          new java.math.BigDecimal(argVariables[3]));                              // clnt_acct_num
         argPs.setBigDecimal     (8,          new java.math.BigDecimal(argVariables[10]));                         // clnt_ckdgt_num
         argPs.setString          (9,          argVariables[11]);                                                            // clnt_sfx_cde
         argPs.setString          (10,     argVariables[12]);                                                            // clnt_prfx_cde
         argPs.setBigDecimal     (11,     new java.math.BigDecimal(argVariables[13]));                         // sod_acct_num
         argPs.setBigDecimal     (12,     new java.math.BigDecimal(argVariables[14]));                         // sod_ckdgt_num
         argPs.setString          (13,     argVariables[15]);                                                            // sod_sfx_cde
         argPs.setString          (14,     argVariables[16]);                                                            // sod_prfx_cde
         argPs.setString          (15,     argVariables[6]);                                                            // reg_cde
         argPs.setShort          (16,     Integer.valueOf(argVariables[7]).shortValue());                    // py_pref_num
         argPs.setString          (17,     argVariables[17]);                                                            // posn_stat_cde
         argPs.setShort          (18,     Integer.valueOf(argVariables[19]).shortValue());                    // py_pref_item_num
         argPs.setShort          (19,     Integer.valueOf(argVariables[25]).shortValue());                    // py_seq_num
         argPs.setString          (20,     argVariables[24]);                                                            // pyb_rcv_cde
         if(argVariables[21] == null || argVariables[21].equals("null")){
                   argPs.setNull(21,java.sql.Types.DATE);
         else{
              argPs.setDate          (21,     java.sql.Date.valueOf(argVariables[21]));                         // clr_dte
         if(argVariables[22] == null || argVariables[22].equals("null")){
                   argPs.setNull(22,java.sql.Types.DATE);
         else{
              argPs.setDate          (22,     java.sql.Date.valueOf(argVariables[22]));                         // stlmt_dte
         if(argVariables[23] == null || argVariables[23].equals("null")){
              argPs.setNull(23,java.sql.Types.DATE);
         else{
              argPs.setDate          (23,     java.sql.Date.valueOf(argVariables[23]));                         // acrl_dte
         argPs.setShort          (24,     Integer.valueOf(argVariables[26]).shortValue());                    //py_seq_item_num
         argPs.setTimestamp     (25,     java.sql.Timestamp.valueOf(argVariables[18]));                         // max(updt_tsp)

  • Urgent, SELECT statement results in error

    hi all, this is very urgent, could you guys have a look at my SELECT statement?
      SELECT vk~kunnr         "customer no
              vk~vbeln         "sales order no
              vk~audat         "date
              vk~vbtyp         "SD DOCUMENT CATEGORY
              vk~knumv         "lwk
              vp~kwmeng        "qty
              vp~matnr         "material no
              vp~posnr         "LINE ITEM
              vd~bstkd         "PURCHASE ORDER NO
    *          kv~kwert         "lwk
              FROM  vbak AS vk
              INNER JOIN vbap AS vp
              ON vk~vbeln = vp~vbeln
              INNER JOIN vbkd AS vd
              ON vk~vbeln = vd~vbeln
    *          INNER JOIN konv AS kv
    *          ON kv~knumv = vk~knumv
              INTO CORRESPONDING FIELDS OF TABLE it_so
              WHERE vk~vkorg IN s_vkorg
              AND vk~audat IN s_date
              AND vk~kunnr IN s_kunnr
              AND vp~matnr IN s_matnr
              AND vd~bstkd IN s_bstkd
              AND vk~vbeln IN s_vbeln
    *          AND kv~kschl = 'ZP00'
              AND vk~vbtyp = 'C'.
    The commented lines are the new additions that i want to add to the SELECT statement. But when i un-comment them, i get an error while activating my program. Error is as follows:
    For pooled tables, cluster tables, and project views, JOIN is not allowed: "KONV".
    Is there a way i can go around it?

    Hi,
    look at this SAP note : 550043
    Symptom
    KEPM: dump 'MESSAGE_TYPE_X' during automatic planning method execution.
    Other terms
    KEPM MESSAGE_TYPE_X transform characteristic value
    Reason and Prerequisites
    This note is related only to cases, if dump 'MESSAGE_TYPE_X' is raising
    during execution of planning method, for which is possible to define
    transformation of characteristics values i.e. Copy, Forecast, Top-Down
    distribution, Ratios and Customer Enhancement.
    Dump is raising in case, if there was defined transformation of char.
    values in parameter set definition for some characteristic. Later on,
    this characteristic was removed from planning level definition but
    characteristic wasn't removed from relevant customizing of transform
    characteristic values before.
    Solution
    Please apply attached program correction.
    Regards,
    GSR.

  • Urgent - prepared statement explanation

    1) I am first setting a String to pull values that are not null ------->
    String customerSqlByExternalId = "SELECT LEAD FROM RECO_PROJECT_TABLE WHERE LEAD IS NOT NULL";
    2) then am calling the PreparedStatement pstmt = getPreparedStatement(customerSqlByExternalId);
    private PreparedStatement getPreparedStatement(String customerSqlByExternalId) throws SQLException {
    return conn.prepareStatement(customerSqlByExternalId);
    3) printing out the results ------------------->
    System.out.println("pstmt.executeQuery()............................................."+pstmt.executeQuery());
    what could it be .....

    Please read the forum FAQ
    https://forums.oracle.com/forums/ann.jspa?annID=1535
    *2. How do I ask a question on the forums?*
    SQL and PL/SQL FAQ
    >
    *2) Thread Subject line*
    Give your thread a meaningful subject, not just "help please", "Query help" or "SQL". This is the SQL and PL/SQL forum. We know your question is going to be about those things, make it meaningful to the type of question so that people with the right sort of knowledge can pick it up and those without can ignore it. Never, EVER, mark your subject as "URGENT" or "ASAP"; this forum is manned by volunteers giving their own time to help and your question is never urgent or more important than their own work or than other people's questions. It may be urgent to you, but that's not forum members issue.
    >
    For urgent issues, please hire a qualified consultant.

  • Urgent help Statement v/s PreparedStatement

    iam using Statement object but java specification says, PreparedStatement makes more efficient compared to Statement object can any body explain briefly about it.

    i know that dynamically u can give values but specification says
    PreparedStatements make the description calls at construction time,
    Statements make them on every execution.what this means If you want to execute a sql statement multiple times, then a prepared statement is more efficient.
    eg
    Statement stmt = connection.createStatement();
    stmt.execute("insert into users (username) values ('Tom')");
    stmt.execute("insert into users (username) values ('Dick')");
    stmt.execute("insert into users (username) values ('Harry')");vs
    [code
    String sql = "]insert into users (username) values (?);";
    stmt = connection.prepareStatement(sql);
    stmt.setString(1, "Tom");
    stmt.execute();
    stmt.setString(1, "Dick");
    stmt.execute();
    stmt.setString(1, "Harry");
    stmt.execute();
    With the first one, the database has to parse the query each time, check it for syntax errors, and then execute it.
    Using a prepared statement, the parsing/error checking only happens once - when you prepare it. After that you can call the same statement with different values, and it will use that already "parsed and prepared" statement.
    It already knows exactly the column types that will be returned from the query - that bit can't change. With a Statement, it has to work from scratch each time.
    If you are executing the same piece of SQL hundreds/thousands of times, only changing the values, then Prepared statements come into their own.
    Cheers,
    evnafets

  • Invalid cursor state error while executing the prepared statement

    hai friends,
    following code showing the invalid cursor state error while executing the second prepared statement.
    pls anyone help me
    String query = "select * from order_particulars where order_no=" + orderno + " order by sno";             psmt1 = conEntry.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);             rs1 = psmt1.executeQuery();             rs1.last();             intRowCount = rs1.getRow();             particularsdata = new Object[intRowCount][6];             rs1.beforeFirst();             if (intRowCount >= 1) {                 for (int i = 0; rs1.next(); i++) {                     particularsdata[0] = i + 1;
    particularsdata[i][1] = rs1.getString(3);
    particularsdata[i][2] = Double.parseDouble(rs1.getString(4));
    rs1.close();
    psmt1.close();
    query = "SELECT sum(delqty) FROM billdetails,billparticulars WHERE order_no= " + orderno + " and " +
    "billdetails.bill_no = billparticulars.bill_no GROUP BY particulars ORDER BY sno";
    psmt1 = conEntry.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    rs1 = psmt1.executeQuery(); //error showing while executing this line

    Also .. Why using arrays instead of collections? Shifting the cursor all the way forth and back to get the count is fairly terrible.
    With regard to the problem: either there's a nasty bug in the JDBC driver used, or you actually aren't running the compiled class version of the posted code.

  • Invalid Number Error Please help Urgent

    Hi,
    I am trying to create a report in discoverer where in I get an invalid number error for the statement
    ,DECODE(final.TYP,'Sales',to_char(final.future_supplpy),'B/O','B/O') sale_type.
    We have the requirement that when TYP is Sales i need to display future supply and when the TYP is B/O i need to display B/O.
    The query runs perfectly fine in TOAD but in Discoverer Desktop when i run the report i get an error message
    invalid number.
    Please help its urgent
    Thanks
    Ashwini

    Hi Ashwani
    First of all, your statement appears to not be handling anything other than Sales or B/O. Is that deliberate? If not, you need a default, catch all value at the end like this:
    DECODE(final.TYP,'Sales',NVL(final.future_supply,to_char(final.future_supply),'B/O','B/O', default_value) sale_type
    You also might want to make sure there aren't any NULL values in future_supply or in TYP and if there are you might want to consider using an NVL for these, like this:
    DECODE(final.TYP,'Sales',NVL(to_char(final.future_supply,NULL),'B/O','B/O', default_value) sale_type
    Also, when using DECODE you don't always need to use TO_CHAR as the DECODE conversion to a string typically takes place automatically. CASE is different as it insists that all results are of the same data type.
    Hope this helps
    Best wishes
    Michael

  • Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (NumberOfMultipleMatches).

    Hi,
    I have a file where fields are wrapped with ".
    =========== file sample
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    "asdsa","asdsadasdas","1123"
    ==========
    I am having a .net method to remove the wrap characters and write out a file without wrap characters.
    ======================
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    asdsa,asdsadasdas,1123
    ======================
    the .net code is here.
    ========================================
    public static string RemoveCharacter(string sFileName, char cRemoveChar)
                object objLock = new object();
                //VirtualStream objInputStream = null;
                //VirtualStream objOutStream = null;
                FileStream objInputFile = null, objOutFile = null;
                lock(objLock)
                    try
                        objInputFile = new FileStream(sFileName, FileMode.Open);
                        //objInputStream = new VirtualStream(objInputFile);
                        objOutFile = new FileStream(sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString(), FileMode.Create);
                        //objOutStream = new VirtualStream(objOutFile);
                        int nByteRead;
                        while ((nByteRead = objInputFile.ReadByte()) != -1)
                            if (nByteRead != (int)cRemoveChar)
                                objOutFile.WriteByte((byte)nByteRead);
                    finally
                        objInputFile.Close();
                        objOutFile.Close();
                    return sFileName.Substring(0, sFileName.LastIndexOf('\\')) + "\\" + Guid.NewGuid().ToString();
    ==================================
    however when I run the bulk load utility I get the error 
    =======================================
    Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 3 (NumberOfMultipleMatches).
    ==========================================
    the bulk insert statement is as follows
    =========================================
     BULK INSERT Temp  
     FROM '<file name>' WITH  
      FIELDTERMINATOR = ','  
      , KEEPNULLS  
    ==========================================
    Does anybody know what is happening and what needs to be done ?
    PLEASE HELP
    Thanks in advance 
    Vikram

    To load that file with BULK INSERT, use this format file:
    9.0
    4
    1 SQLCHAR 0 0 "\""      0 ""    ""
    2 SQLCHAR 0 0 "\",\""   1 col1  Latin1_General_CI_AS
    3 SQLCHAR 0 0 "\",\""   2 col2  Latin1_General_CI_AS
    4 SQLCHAR 0 0 "\"\r\n"  3 col3  Latin1_General_CI_AS
    Note that the format file defines four fields while the fileonly seems to have three. The format file defines an empty field before the first quote.
    Or, since you already have a .NET program, use a stored procedure with table-valued parameter instead. I have an example of how to do this here:
    http://www.sommarskog.se/arrays-in-sql-2008.html
    Erland Sommarskog, SQL Server MVP, [email protected]

  • 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

  • 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
    ;

  • Error with ExecuteQuery() in prepared statement

    Hello,
    i' m a new one at java. I' m trying to build a web application in jsp and i have a problem in a simple at log in authentication.
    My code is this:
    <html>
    <head>
    <title>Welcome to the online Boat Shop, Inc.</title></head>
    <body>
    <%@ page language ="java" import = "java.io.*, java.lang.*, java.sql.*" %>
    <% try
    String strUsername = request.getParameter("USERNAME");
    String strPassword = request.getParameter("PASSWORD");
    Class.forName ("org.apache.derby.jdbc.ClientDriver");
    Connection myConn = DriverManager.getConnection("jdbc:derby://localhost:1527/boatsdb","tony", "logo");
    String strSQL = "SELECT USERNAME, PASSWORD FROM BOATDB where USERNAME = ? and PASSWORD = ?";
    PreparedStatement stmt = myConn.prepareStatement(strSQL);
    stmt.setString(1, "USERNAME");
    stmt.setString(2, "PASSWORD");
    ResultSet myResult = stmt.executeQuery(strSQL);
    if(myResult.next()){
    out.println("Login Succesful! A record with the given user name and password exists");
    } else {
    out.println("Login Failed. No records exists with the given user name and password");
    myResult.close();
    stmt.close();
    myConn.close();
    } catch(Exception e){
    out.println(e);
    %>
    </body>
    </html>
    The problem is that prepared statement doesn't support executeQuery() method and i can find any solution. The error is this:
    java.sql.SQLException: Method 'executeQuery(String)' not allowed on prepared statement. I already have some data in my database so that it can return results.
    Thank you.
    Edited by: antonis on May 3, 2008 6:13 AM

    thank you, that was the problem. It seems that i have also done mistakes in passing the username and password from the forms to the database for checking, because the message that i get always when i log is that there is no user with this username kai password.
    <form method=GET action=log1.jsp>
    <font size=5> Username <input type=text name="USERNAME" size=20>
              </font>
              <br>
              <font size=5> Password <input type=text name="PASSWORD" size=20>
              </font>
              <br>
              <input type=submit name=action value="Submit">
    </form>
    That's the forms and combined with the code in the fist post should have worked. Any ideas?
    thanks again.

  • Invalid Number Error in Merge Statement

    Hi all.
    I got an invalid number error in the following merge statement, but I don't know why. Maybe you can give me a hint.
    MERGE INTO wam_table
    USING (SELECT * FROM wam_table) b
    ON (b.username = 'user'
    AND b.mod = 'module'
    AND b.trimester = '1')
    WHEN MATCHED THEN
    UPDATE SET as = '1', ad = '1', co = '1', pr = '1', date = localtimestamp, lus = 'username'
    WHEN NOT MATCHED THEN
    INSERT VALUES ('user','module','1','1','1','1','1', localtimestamp, 'username');
    The invalid number error appears in the first line, but I don't know why?
    Stephan

    UPDATE SET as = '1', ad = '1', co = '1', pr = '1', date = localtimestamp, lus = 'username'SELECT * FROM sys.v_$reserved_words;
    SQL> create table test1(as varchar2(10));
    create table test1(as varchar2(10))
    ERROR at line 1:
    ORA-00904: : invalid identifier
    SQL> create table test1(sno number, date date);
    create table test1(sno number, date date)
    ERROR at line 1:
    ORA-00904: : invalid identifier
    SQL> create table test1("as" varchar2(10));
    Table created.
    SQL>
    SQL> create table test2(sno number, "date" date);
    Table created.
    SQL> desc test1
    Name                                      Null?    Type
    as                                                 VARCHAR2(10)
    SQL> desc test2
    Name                                      Null?    Type
    SNO                                                NUMBER
    date                                               DATE
    SQL> 

  • Error handling in prepared statement batch

    Hi,
    For a prepared statement batch, it is not possible to know which operation failed. ... You should always perform a ROLLBACK operation in this situation.
    For a generic statement batch or callable statement batch, the update counts array is only a partial array containing the actual update counts up to the point of the error. ... You can either commit or roll back the successful operations in this situation, as you prefer.
    -- http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/oraperf.htm#1056233
    But, I want to skip failed operations and continue to excecute the remains of the batch, also, I want to improve application performance, what should I do? Is there any choice?
    Best Regards,
    Kevin Zhao

    According to the Oracle docs these are not the only possible values:
    Oracle9i JDBC Developer's Guide and Reference
    Release 2 (9.2) chapter 12
    Performance Extensions
    "For a prepared statement batch, it is not possible to know which operation failed. The array has one element for each operation in the batch, and each element has a value of -3. According to the JDBC 2.0 specification, a value of -3 indicates that an operation did not complete successfully. In this case, it was presumably just one operation that actually failed, but because the JDBC driver does not know which operation that was, it labels all the batched operations as failures."
    It goes on to say that for a generic statement batch it is possible to know which failed. I would like to know if similar functionality will be available for prepared statement batches in the future.

  • Db2 - bea jdbc type 4 driver error - cursor not in a prepared state

    Hi
    I am getting this error from BEA DB2 Driver in weblogic console.
    java.sql.SQLException: [BEA][DB2 JDBC Driver][DB2]CURSOR C02 NOT IN A
    PREPARED STATE
    This problem occurs frequently almost everyday.
    When this error happens we clear the statement cache by logging in to the weblogic console (which clears the cache of prepared and callable statements maintained for each connection in the connection pool), and will be able to proceed till the error comes up again!
    Has anyone come across this type of error?
    DB2 UDB V8.1 Fixpack 4 on Solaris
    Weblogic V8.1 SP2
    Thanks
    Sireesh.

    We have seen that error as well. When using entity beans, we could do some creates, but then we would get the Cursor error. It would happen sporadically.
    IBM now has better Type 4 drivers with version 8.2, we are having better luck with them then with the BEA drivers.

Maybe you are looking for

  • F150 dunning prog. and Gregorian calendar-wrong interest rates calculation

    Hello everyone, I have a problem with F150 - dunnning program and the Gregorian Calendar. I defined a interest rate indicator and I choose Gregorian calendar - 365 days in the year but SAP calculate 360 days and the interest rates are wrong u2013 to

  • Java.lang.NullPointerException when extending controller

    Hi, I am working in Oracle Internet expenses module. My requirement is to check 2 values in a page and if any of them is NULL, i need to throw an error message on the page. Code snippet in the extended controller is: (In the method 'processFormReques

  • Xml file icon not showing

    Hi, I recently installed Dreamweaver CS4 on my Vista Business 32bit. By default xml files are associated to open with Dreamweaver, however the icon that is being displayed for the xml files is a blank paper icon. All the other files like .css, .js et

  • Installing Windows XP Pro alongside Windows 7 & Mac OS/X Snow Leopard

    I am running mac os/x snow leopard. I have partitioned my hard disk three ways: Mac OS (journaled), Windows 7 and a third partition on which I intend to install Windows XP Pro. The 3rd partition is formatted NTFS. My understanding is that if I were t

  • What's new isn't on the Google now launcher anymore

    This isn't a complaint but when I swipe up to use Google now the what's new icon doesnt appear if someone could tell me how I did this it would be much appreciated thanks