Fail to convert to internal representation: oracle.sql.DATE

I'm using the oracle 8.1.7 jdbc driver against oracle 8.1.7 running on NT, and I get the exception message below when I attempt to insert an jpub object structure into a prepared statement.
All date objects have been constructed from a timestamp object, using the oracle.sql.DATE Timestamp constructor. So I'm surprised to get this error given the timestamp object was successfully constructed.
I've tried session date formats of 'yyyy-mm-dd hh24:mi:ss' and 'mm/dd/yyyy hh24:mi:ss', with no success.
I can call stringValue on oracle.sql.DATE and it returns a valid date.
Can someone confirm that they have been able to use the oracle.sql.DATE class to insert a date correctly into the database? Its seems a silly question to ask but you have to start somewhere!
Exception : Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
Stack trace : java.sql.SQLException: Fail to convert to internal representation: oracle.sql.DATE@3c144e8a
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:261)
at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:385)
at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:560)
at oracle.sql.STRUCT.<init>(STRUCT.java:95)
at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:65)
null

The JPub/JDBC runtime is converting your Java object into Oracle-specific representation (all data is put in oracle.sql.XXXX format). The top level object is an oracle.sql.STRUCT, the attributes of which are represented as an array of oracle.sql.Datum objects - in your case an oracle.sql.NUMBER and an oracle.sql.DATE. However, the error does occur in the StructDescriptor which describes the SQL type and the shape of the object. Is the error dependent on the data values? Might null values not be dealt with, correctly?
One thing to try to do is create such an oracle.sql.STRUCT object from scratch with the same attribute values and insert/manipulate that using SQL.
I have not dealt with TAR's. If you send me a self-contained test case, I'll check it against the current development version of JDBC. (At least you'll know if the next JDBC release fixes this issue :-) I might also file a bug.

Similar Messages

  • Java.sql.SQLException: Fail to convert to internal representation:

    HI All,
    I have a procedure hich is taking the Varray ADDR_CONTACT_VA as input which is varray of object .
    ADDR_CONTACT_OBJ [] address = new ADDR_CONTACT_OBJ[20];
    address[0] = new ADDR_CONTACT_OBJ();
    address[0].setOpportunityId(26731);
    address[0].setAddr_ln_1("100, Street");
    address[0].setAddr_ln_2("Cast card Street");
    address[0].setAddr_ln_3("Cast card Street");
    address[0].setAddr_ln_4(null);
    address[0].setAddr_ln_5(null);
    address[0].setAddr_ln_6(null);
    address[0].setAddress_name("GVPN Testing");
    address[0].setAddressType("HQ");
    address[0].setCity("Mumbai");
    address[0].setContact_title("Mr.");
    address[0].setCountry("India");
    address[0].setEmail_contact_id(null);
    address[0].setName_contact_id(null);
    address[0].setOSO_Address_id(124959);
    address[0].setOso_contact_id(317694);
    address[0].setOso_party_site_id(69387);
    address[0].setPincode("470003");
    address[0].setState("Maharashtra");
    address[0].setContact_firstname("First");
    address[0].setContact_lastname("Last");
    address[0].setContact_email(null);
    address[0].setContact_phone_day("91-45234-4534556");
    address[0].setDay_phone_contact_id(287326);
    System.out.println("Vishwa3: after creating an y array");
    ArrayDescriptor desc1 = ArrayDescriptor.createDescriptor("ADDR_CONTACT_VA",nativeConnection);
    System.out.println("Vishwa4: after creating an y array");
    ARRAY input1 = new ARRAY(desc1,nativeConnection,address);
    System.out.println("Vishwa5: after creating an y array");
    %>
    <% proc_stmt = (OracleCallableStatement)nativeConnection.prepareCall("{ call DBP_UPDATE_STATUSCUSTOMER_DETAILS(?,?)}");
    proc_stmt.setArray(1,input1);
    proc_stmt.registerOutParameter(2,OracleTypes.CURSOR);
    System.out.println("Vishwa6: after creating an y array");
    %>
    <% proc_stmt.execute();
    ResultSet result =(ResultSet)proc_stmt.getObject(2);
    while(result!=null)
    System.out.println(result.getString(1));
    System.out.println(result.getString(2));
    System.out.println(result.getString(3));
    System.out.println(result.getString(4));
    System.out.println(result.getString(5));
    when i try to execute this procedure ai m gettin the exception like
    java.sql.SQLException: Fail to convert to internal representation: com.sy.vo.ADDR_CONTACT_OBJ@4a594a59_
    Please help me to resolve this probelm .it is verey verey urgrnt for me
    Thanks in Advance.....................
    Viswa

    First use code tags when posting code.
    Second you can't simply use a java object as an database array type. It certainly looks like you are doing that.

  • Wm_Valid: Fail to convert to internal representation error while inserting

    Hi,
    I'm trying to execute an insert via XmlCommand. The table is created with this statement:
    create table testtable4 (testtable4_pk number, mydate date, myts timestamp with time zone, wm_valid wm_period);
    I have a problem while inserting on a simple table with wm_period field. The c# code is the following:
    OracleConnection oraConnection;
    OracleCommand insertCommand;
    string[] KeyColumnsList = null;
    string[] UpdateColumnsList = null;
    string xml1 = "<?xml version=\"1.0\"?>\n" +
    "<ROWSET>\n" +
    "<MYROW num = \"1\">\n" +
    "<TESTTABLE4_PK>1</TESTTABLE4_PK><MYDATE>2012-01-20T00:00:00.00000</MYDATE><MYTS>01-01-11T00:00:00.000000000 +00:00</MYTS>" +
    "</MYROW>\n" +
    "</ROWSET>\n";
    string xml2 = "<?xml version=\"1.0\"?>\n" +
    "<ROWSET>\n" +
    "<MYROW num = \"2\">\n" +
    "<TESTTABLE4_PK>2</TESTTABLE4_PK><MYDATE>2012-01-20T00:00:00.00000</MYDATE><MYTS>01-01-11T00:00:00.000000000 +00:00</MYTS><WM_VALID><VALIDFROM>01-01-11T00:00:00.000000000 +00:00</VALIDFROM></WM_VALID>" +
    "</MYROW>\n" +
    "</ROWSET>\n";
    KeyColumnsList = new string[1];
    KeyColumnsList[0] = "TESTTABLE4_PK";
    UpdateColumnsList = new string[4];
    UpdateColumnsList[0] = "TESTTABLE4_PK";
    UpdateColumnsList[1] = "MYDATE";
    UpdateColumnsList[2] = "MYTS";
    UpdateColumnsList[3] = "WM_VALID";
    try
    string ConnString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + host + ")(PORT=" + port + ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" + sid + ")));User Id=" + username + ";Password=" + password + ";";
    oraConnection = new OracleConnection(ConnString);
    oraConnection.Open();
    using (OracleCommand cmd = new OracleCommand())
    cmd.Connection = oraConnection;
    cmd.CommandText = "alter session set NLS_DATE_FORMAT = 'YYYY-MM-DD\"T\"HH24:MI:SS.SSSSS'";
    cmd.ExecuteNonQuery();
    cmd.CommandText = "alter session set NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD\"T\"HH24:MI:SS.SSSSS'";
    cmd.ExecuteNonQuery();
    cmd.CommandText = "alter session set NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD\"T\"HH24:MI:SSXFF TZH:TZM'";
    cmd.ExecuteNonQuery();
    insertCommand = new OracleCommand();
    insertCommand.Connection = oraConnection;
    insertCommand.XmlCommandType = OracleXmlCommandType.Insert;
    insertCommand.XmlSaveProperties.KeyColumnsList = KeyColumnsList;
    insertCommand.XmlSaveProperties.RowTag = "MYROW";
    insertCommand.XmlSaveProperties.Table = "TESTTABLE4";
    insertCommand.XmlSaveProperties.UpdateColumnsList = UpdateColumnsList;
    insertCommand.XmlSaveProperties.Xslt = null;
    insertCommand.XmlSaveProperties.XsltParams = null;
    //this works
    insertCommand.CommandText = xml1;
    insertCommand.ExecuteNonQuery();
    //this fails
    insertCommand.CommandText = xml2;
    insertCommand.ExecuteNonQuery();
    insertCommand.Dispose();
    oraConnection.Close();
    oraConnection.Dispose();
    catch (Exception err)
    this.WriteLogErr("ERROR: " + err.Message);
    With the first ExecuteNonQuery I attempt an insert of a data value and a timestamp with timezone value. The execution is ok (xml1).
    When the second ExecuteNonQuery is run (with the value of wm_valid), the execution fails with this error:
    ERROR: ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: 'java.sql.SQLException: Fail to convert to internal representation: 01-01-11T00:00:00.000000000 +00:00' encountered during processing ROW element 0. All prior XML row changes were rolled back. in the XML document.
    ORA-06512: at "SYS.DBMS_XMLSAVE", line 111
    ORA-06512: at line 1
    The stored procedure at row 111 calls this Java method:
    oracle.xml.sql.dml.OracleXMLStaticSave.insertXML(int, java.lang.String) return int
    The structure of complex data type wm_period is:
    CREATE OR REPLACE TYPE wm_period AS OBJECT (
    validfrom TIMESTAMP WITH TIME ZONE,
    validtill TIMESTAMP WITH TIME ZONE);
    The problem is: I am able to insert a timestamp with timezone value (myts) but I'm not able to insert a wm_valid that contains two values of the same type...
    This works: <MYTS>2011-01-01T00:00:00.00000</MYTS>
    This fails: <WM_VALID><VALIDFROM>2011-01-01T00:00:00.00000</VALIDFROM></WM_VALID>
    I also tried to change the format of NLS_TIMESTAMP_TZ_FORMAT with a lot of various setup, but nothing changed.
    Thanks in advance for your precious help.
    Best Regards,
    Mario.

    Hi jschell ...thnx for ur reply......
    the getString(2) parameter is just avarchar which
    return the error from the procedure, if its ok,then
    the query is executed properly..its just a check I've
    kept to jump into the next step.If the status is OK,
    then I'm retrieving the values from the cursor. I'm
    getting right value for this parameter.I wasn't questioning the logic. I understand what you are doing.
    However JDBC drivers can have problems when items are retrieved out of order.
    You might also try switching driver types. If the thin works and oci doesn't (or visa-versa) then you know it is a driver problem and you will just have to try a work around.

  • Fail to convert to internal representation

    I'm using the oracle 8.1.7 jdbc driver against oracle 8.1.7.0.0 running on Windows2000. I get the exception message below when I attempt to insert an jpub object structure into a callable statement.
    java.sql.SQLException: Fail to convert to internal representation: com.neogenesis.alis.confirmation.mapping.JHitCollection@536ff3
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:829)
    at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:299)
    at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:137)
    at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:750)
    at oracle.sql.ARRAY.<init>(ARRAY.java:116)
    Is this a bug of JDBC driver? Any Clue?
    Thanks,
    -Charlie

    From the stacktrace, it looks like a problem. However, if you can provide more code for this. We can figure out what went wrong. By the way, did you try this on Windows NT?
    -cc

  • Sql Exception: Fail to convert to internal representation

    Hi
    I have a column in my ORACLE table defined as
    INTGROUPID NUMBER(10).
    When I try to select some rows from that table with a condition using this column "INTGROUPID" by the below code, I am getting the above metioned error.
    Code :
    select *
    from Sri.TBLGROUPCOCK
    where
    INTGROUPID = TO_NUMBER('747');

    actually the to_number command is used to convert a string to number..ok..but u used it to convert a number.how could it be possible to you.So there is no need to convert a number to number.just use the normal command to get the elements in the table...
    i hope it will help u......!

  • Sql Exceptionjava.sql.SQLException: Fail to convert to internal representat

    Hai,
    I tryed to execute the following code and getting the error as
    Sql Exceptionjava.sql.SQLException: Fail to convert to internal representation.
    try{
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   connection= DriverManager.getConnection("jdbc:oracle:thin:@180.190.30.30:1521:jb3db1","jbl_pathart","jbl_pathart");
    statment=connection.prepareStatement (
                                  "SELECT path.pathway_name, phy.physiology_name, org.organism_name, path.is_physiology," +
                                  " jpty.pathway_type_name, path.pathway_id" +
                                  " FROM pathway path, physiology phy, organism org, jbl_pathway.pathway_type jpty "+
                                  " WHERE path.physiology_id = phy.physiology_id "+
                                  " AND path.organism_id = org.organism_id "+
                                  " AND path.pathway_type_id = jpty.pathway_type_id "+
                                  " AND path.pathway_id = " + i);
                        ResultSet rs=statment.executeQuery();
                        while(rs.next()){                    
                             orgName          = rs.getString(1);
                             phyName          = rs.getString(2);
                             pathwayName     = rs.getString(3);
                             is_physiology     = rs.getString(4);
                             pathwayId          = rs.getInt(5);
    } catch (Exception e){
                   System.out.println("Sql Exception"+e);
         }

    Please do this first...replace the following bit of code:
    } catch (Exception e){
    System.out.println("Sql Exception"+e);
    }with
    } catch (Exception e){
        e.printStackTrace();
    }If you do this, it'll even tell you exactly which line is throwing the exception.

  • Conversion failed when converting the varchar value 'undefined' to data typ

    Conversion failed when converting the varchar value 'undefined' to data type int.
    hi, i installed oracle insbridge following the instruction in the manual. in rate manager, when i tried to create a new "Normal rating" or "Underwriting", im getting the following exception
    Server Error in '/RM' Application.
    Conversion failed when converting the varchar value 'undefined' to data type int.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.Data.SqlClient.SqlException: Conversion failed when converting the varchar value 'undefined' to data type int.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [SqlException (0x80131904): Conversion failed when converting the varchar value 'undefined' to data type int.]
    System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1948826
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4844747
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
    System.Data.SqlClient.SqlDataReader.HasMoreRows() +157
    System.Data.SqlClient.SqlDataReader.ReadInternal(Boolean setTimeout) +197
    System.Data.SqlClient.SqlDataReader.Read() +9
    System.Data.SqlClient.SqlCommand.CompleteExecuteScalar(SqlDataReader ds, Boolean returnSqlValue) +50
    System.Data.SqlClient.SqlCommand.ExecuteScalar() +150
    Insbridge.Net.Fwk.DAO.DataAccess.ScalarQuery(String connectionString, String command, Transaction transType, Object[] procParams) +110
    [Exception: Cannot Execute SQL Command: Conversion failed when converting the varchar value 'undefined' to data type int.]
    Insbridge.Net.Fwk.DAO.DataAccess.ScalarQuery(String connectionString, String command, Transaction transType, Object[] procParams) +265
    Insbridge.Net.Fwk.DAO.SqlProcessor.ExecuteScalarQueryProc(String subscriber, String datastore, String identifier, String command, Transaction transType, Object[] procParams) +101
    Insbridge.Net.Fwk.DAO.SqlProcessor.ExecuteScalarQuery(String subscriber, String identifier, String command) +22
    Insbridge.Net.RM.IBRM.ExeScalar(String cmd, Object[] paramsList) +99
    Insbridge.Net.RM.Components.Algorithms.AlgEdit.Page_Load(Object sender, EventArgs e) +663
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
    System.Web.UI.Control.OnLoad(EventArgs e) +99
    System.Web.UI.Control.LoadRecursive() +50
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
    my insbridge versions are as follows
    IBRU 4.0.0 Copyright ©2010, Oracle. All rights reserved. - Version Listing
    RMBUILD.DLL 4.0.0.0 (x86)
    SRLOAD.DLL 3.13.0 (x86)
    IBRM v04.00.0.17
    IB_CLIENT v04.00.0.00
    RM.DLL 4.00.0 (x86)
    IBFA 3.0.2
    OS: Windows Server 2003
    DB: Sql Server 2008
    Browser: IE8
    how do i solve this, please help

    This is an error due to conversion failed from character string to int datatype. Infact, the table column contains "NO" value which you are trying to convert to Int/SUM which is illegal. Without your code and table structure, its difficult to pinpoint your
    actual issue. But check, all columns for value "NO". 

  • Convert a String to java.sql.Date Format

    Hi,
    I am having a String of containing date in the format 'dd/mm/yyyy' OR 'dd-MMM-YYYY' OR 'mm-dd-yyyy' format. I need to convert the string to java.sql.Date object so that I can perform a query the database for the date field. Can any one suggest me with the code please.
    Regards,
    Smitha

    import java.text.SimpleDateFormat;
    import java.text.ParseException;
    import java.util.Date;
    public class TestDateFormat
         public static void main(String args[])
              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
              System.out.println(sdf.isLenient());
              try
                   Date d1 = sdf.parse("07-11-2001");
                   System.out.println(d1);
                   Date d2 = sdf.parse("07:11:2001");
                   System.out.println(d2);
              catch(ParseException e)
                   System.out.println("Error format, " + e);
    See class DateFormat and SimpleDateFormat for detail.

  • Oracle.sql.DATE documentation also missing

    Thanks for the documentation of jbo.domain.Date, but it was not enough.
    I need to know how to use the toDate method, but it seen to be described in the superclass
    oracle.sql.DATE that was also missing in documentation.
    I have searched at OTN docs, but it's also missing there.
    There is some place where this documentation is stored in OTN, since could be others classes missing.
    Thanks for the support.

    I'm trying to set a date value and keep getting a ClassCastException:
    rsaDemandException is a ScrollableRowsetAccess object
    "StartDate" is a valid Date type column in the DemandException view object
    newDate is a Date object of the various types I have tried below
    The line that causes an exception to be thrown:
    rsaDemandException.setColumnValue("StartDate", newDate);
    I've tried the following objects for newDate
    java.util.Date;
    java.sql.Date;
    java.sql.Timestamp;
    oracle.sql.DATE;
    oracle.jbo.domain.Date;
    None of them work. They all throw a class cast exception.
    Any hints on what I need to do? Or is this some bug?
    null

  • Oracle SQL Data Modeler -COMPARE/MERGE

    Hi all,
    I am trying to compare/merge or just trying to merge a relation model with another in Oracle SQL Developer DATA MODELER.
    Scenario:
    I have tried to import from data dictionary the hr schema into 3 parts.
    Table employee is alone imported in one design model's relational model(say DataModelerDesign1- DMD1).
    Table Departments,Locations and Countries in another design model's relational model(say DMD2).
    Table Job_history,Jobs and Regions in another design model's relational model(say DMD3).
    Now, I tried to merge all this into one design model's relational model, here into DMD3.
    Requirement:
    I want all of this relational model's tables to get merged with exact mappings as if it is in HR schema all connected to each other. But they are all getting merged as separate entities not conencted to each other when taken from Compare/merge option. How should i do this task?
    Issues:
    1) I can never see anything in the compare model when i try to click on view compare mapping. Can anytime we see any data here?
    2) In realtime scenario, when will we try to merge a table into another or split it. Because some foriegn key violations are happening here. Is it ever possible to succeed our requirement while merging itself instead of creating relationships between entities manually in main relationship model DMD3 in example here.

    I have found on occasions the diagram pdf would be missing a few relationship lines. Usually it happens after I have been doing a lot of work in the tool or printing a bunch of diagrams. Seems to be a memory leak of some sort. If I close Data Modeler, re-open it, then print to PDF, the diagram is fine.

  • Convert a string to JAva.sql.date..

    I am having a string with the value as follows..
    String fval="03-10-2001"..
    I am using this value in a rs.updateDate method where I need to convert it to a different format as
    2001-10-03...can anybody give me the syntax..

    You should hold dates as Date instances. But if you want to convert between Strings and Dates then you should use a DateFormat:
    String originalDateString = "31-10-2001";
    // Convert the original string to a date
    DateFormat originalDateFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date date = originalDateFormat.parse(originalDateString);
    // Get a representation of the date in the new format
    DateFormat newDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String newDateString = newDateFormat.format(date);(Excuse the quirky formatting that the Java code filter applies!)
    Hope this helps.

  • Oracle SQL- Date/Time Help

    Hi I have a query that generates a roster report.
    The issue I am having is how do I create a query the runs off the start and end time.
    What I mean by this is, no matter what time of the day it is, I want the query to run based off of the between time of start and end, if that makes sense.
    Below is an example, notice the double entry, (and yes it is correct) the issue is that both these records get picked up, I would like my query to be based off what the time of day is.
    If it is 12PM, to send 1st record, if its 1:46 pm, to send 2nd record, not both.
    Any help... please
    Employee ID First Last Unit Abr Staffing Start Dt Staffing End DT wstat_name_ch wstat_type_no_in
    '015428'     Jason     Xi     'P23'     '2012-09-10 11:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          3
    '015428'     Jason     Xi     'P77'     '2012-09-10 13:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          1
    --My query for above statement.
    SELECT DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
    DBA.Resource_Master_Tbl.RscMaster_FName_Ch, DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.wstat_cde_tbl.wstat_type_no_in
    FROM DBA.resource_tbl, DBA.Resource_Master_Tbl, DBA.staffing_tbl, DBA.wstat_cde_tbl, DBA.position_tbl, DBA.unit_tbl
    WHERE DBA.resource_tbl.RscMaster_No_In = DBA.Resource_Master_Tbl.RscMaster_No_In AND DBA.resource_tbl.rsc_no_in = DBA.staffing_tbl.rsc_no_in AND
    DBA.staffing_tbl.wstat_no_in = DBA.wstat_cde_tbl.wstat_no_in AND DBA.staffing_tbl.pos_no_in = DBA.position_tbl.pos_no_in AND
    DBA.position_tbl.unit_no_in = DBA.unit_tbl.unit_no_in AND (DBA.staffing_tbl.staffing_start_dt <= NOW()) AND
    (DBA.staffing_tbl.staffing_end_dt >= NOW()) AND (DBA.wstat_cde_tbl.wstat_type_no_in = 1 OR
    DBA.wstat_cde_tbl.wstat_type_no_in = 3)
    GROUP BY DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch, DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
    DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_type_no_in
    ORDER BY DBA.Resource_Master_Tbl.RscMaster_FName_Ch

    958211 wrote:
    Hi I have a query that generates a roster report.
    The issue I am having is how do I create a query the runs off the start and end time.
    What I mean by this is, no matter what time of the day it is, I want the query to run based off of the between time of start and end, if that makes sense.
    Below is an example, notice the double entry, (and yes it is correct) the issue is that both these records get picked up, I would like my query to be based off what the time of day is.
    If it is 12PM, to send 1st record, if its 1:46 pm, to send 2nd record, not both.
    Any help... please
    Employee ID First Last Unit Abr Staffing Start Dt Staffing End DT wstat_name_ch wstat_type_no_in
    '015428'     Jason     Xi     'P23'     '2012-09-10 11:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          3
    '015428'     Jason     Xi     'P77'     '2012-09-10 13:45:00.000'     '2012-09-11 11:45:00.000'     'Regular Duty'          1
    --My query for above statement.
    SELECT DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
    DBA.Resource_Master_Tbl.RscMaster_FName_Ch, DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.wstat_cde_tbl.wstat_type_no_in
    FROM DBA.resource_tbl, DBA.Resource_Master_Tbl, DBA.staffing_tbl, DBA.wstat_cde_tbl, DBA.position_tbl, DBA.unit_tbl
    WHERE DBA.resource_tbl.RscMaster_No_In = DBA.Resource_Master_Tbl.RscMaster_No_In AND DBA.resource_tbl.rsc_no_in = DBA.staffing_tbl.rsc_no_in AND
    DBA.staffing_tbl.wstat_no_in = DBA.wstat_cde_tbl.wstat_no_in AND DBA.staffing_tbl.pos_no_in = DBA.position_tbl.pos_no_in AND
    DBA.position_tbl.unit_no_in = DBA.unit_tbl.unit_no_in AND (DBA.staffing_tbl.staffing_start_dt <= NOW()) AND
    (DBA.staffing_tbl.staffing_end_dt >= NOW()) AND (DBA.wstat_cde_tbl.wstat_type_no_in = 1 OR
    DBA.wstat_cde_tbl.wstat_type_no_in = 3)
    GROUP BY DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch, DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
    DBA.Resource_Master_Tbl.RscMaster_LName_Ch, DBA.unit_tbl.unit_abrv_ch, DBA.wstat_cde_tbl.wstat_name_ch, DBA.wstat_cde_tbl.wstat_abrv_ch,
    DBA.staffing_tbl.staffing_start_dt, DBA.staffing_tbl.staffing_end_dt, DBA.wstat_cde_tbl.wstat_type_no_in
    ORDER BY DBA.Resource_Master_Tbl.RscMaster_FName_ChFor your own sanity, you should learn to format your code. For the sanity of those of whom you are requesting assistance, you should preserve that formatting with the use of the code tags
    SELECT
        DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
        DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
        DBA.Resource_Master_Tbl.RscMaster_LName_Ch,
        DBA.unit_tbl.unit_abrv_ch,
        DBA.staffing_tbl.staffing_start_dt,
        DBA.staffing_tbl.staffing_end_dt,
        DBA.wstat_cde_tbl.wstat_name_ch,
        DBA.wstat_cde_tbl.wstat_abrv_ch,
        DBA.wstat_cde_tbl.wstat_type_no_in
    FROM
        DBA.resource_tbl,
        DBA.Resource_Master_Tbl,
        DBA.staffing_tbl,
        DBA.wstat_cde_tbl,
        DBA.position_tbl,
        DBA.unit_tbl
    WHERE
        DBA.resource_tbl.RscMaster_No_In = DBA.Resource_Master_Tbl.RscMaster_No_In
    AND DBA.resource_tbl.rsc_no_in = DBA.staffing_tbl.rsc_no_in
    AND DBA.staffing_tbl.wstat_no_in = DBA.wstat_cde_tbl.wstat_no_in
    AND DBA.staffing_tbl.pos_no_in = DBA.position_tbl.pos_no_in
    AND DBA.position_tbl.unit_no_in = DBA.unit_tbl.unit_no_in
    AND (DBA.staffing_tbl.staffing_start_dt <= NOW())
    AND (DBA.staffing_tbl.staffing_end_dt >= NOW())
    AND (DBA.wstat_cde_tbl.wstat_type_no_in = 1
         OR
         DBA.wstat_cde_tbl.wstat_type_no_in = 3)
    GROUP BY
        DBA.Resource_Master_Tbl.RscMaster_EmployeeID_Ch,
        DBA.Resource_Master_Tbl.RscMaster_FName_Ch,
        DBA.Resource_Master_Tbl.RscMaster_LName_Ch,
        DBA.unit_tbl.unit_abrv_ch,
        DBA.wstat_cde_tbl.wstat_name_ch,
        DBA.wstat_cde_tbl.wstat_abrv_ch,
        DBA.staffing_tbl.staffing_start_dt,
        DBA.staffing_tbl.staffing_end_dt,
        DBA.wstat_cde_tbl.wstat_type_no_in
    ORDER BY
        DBA.Resource_Master_Tbl.RscMaster_FName_ChI'm not sure the above is even legal Oracle SQL. Are you sure you aren't taking code from some other rdbms?

  • Conversion failed when converting the nvarchar value 'MX_PERSON' to data type int

    Hi,
    I am trying to check user status by running this query: my query take as input the userid= 'USER1234' as parameter
    select count (distinct mskey) from idmv_vallink_basic_active where mcAttrName='MSKEYVALUE' and mcSearchValue='USER1234'
      and mskey in (select mskey from idmv_vallink_basic_active where mcattrname='MX_DEPARTEMENT' and mcsearchvalue between 20 and 50)
      and mskey in (select mskey from idmv_vallink_basic_active where mcattrname='Z_TYPE' and mcsearchvalue = 'LOCAL')
      and mskey not in (select mskey from idmv_vallink_basic_active where mcattrname='ZPOSITION1' and mcsearchvalue = '12345') 
      and mskey not in (select mskey from idmv_vallink_basic_active where mcattrname='ZPOSITION2' and mcsearchvalue = '12345')
    I am using IDM 7.2 Sp7.
    Can you help me to correct this query? Should I use idmv_entry_simple as start?
    Michaela

    Hi Michaela,
    I would recommend you to use idmv_value_* for non reference attributes and idmv_link_* for reference attributes for performance reasons. Try this:
    count (distinct mskeyvalue.mskey) from idmv_value_basic_active mskeyvalue, idmv_value_basic_active department,
    idmv_value_basic_active type_, idmv_value_basic_active position1, idmv_value_basic_active position2
    where mskeyvalue.SearchValue = 'MSKEYVALUE' and mskeyvalue.SearchValue = 'USER1234'
    and department.SearchValue = 'MX_DEPARTEMENT' and department.SearchValue between 20 and 50
    and type_.SearchValue = 'Z_TYPE' and type_.SearchValue = 'LOCAL'
    and position1.SearchValue = 'ZPOSITION1' and position1.SearchValue = '12345'
    and position2.SearchValue = 'ZPOSITION2' and position2.SearchValue = '12345'
    and mskeyvalue.mskey = department.mskey and mskeyvalue.mskey = type_.mskey and mskeyvalue.mskey = position1.mskey
    and mskeyvalue.mskey = position2.mskey
    Regards
    Norman

  • Error in MS Visual Studio 2010 : Conversion failed when converting the nvarchar value '@VATSchemeType' to data type int.

    This worked well in Visual studio 2005, but in the 2010 version it gives the above error
    SELECT VT_ClientCore.ClientCode
     ,VT_VATScheme.SchemeName
          ,CI_Entity.Name as 'Client Name'
          ,SY_Address.Address1
     ,SY_Address.Address2
    ,SY_Address.Address3
     ,SY_Address.Address1
     +(CASE WHEN (Address2 is Null OR Address2 = '') THEN '' ELSE ', ' + Address2 END)
                      + (CASE WHEN (Address3 is Null OR Address3 = '') THEN '' ELSE ', ' + Address3 END)
                      as 'Address123'
    ,SY_Address.City
    ,VT_ClientCore.VATOffice
    ,VT_ClientCore.NatureOfBusiness
    ,SY_Address.PostalCode
    ,SY_Country.Description as 'Country'
    --CASE WHEN (PostalCode IS NULL THEN)
    FROM VT_ClientCore
    LEFT JOIN VT_ClientPack ON VT_ClientCore.EntityCode#ClientCore = VT_ClientPack.EntityCode#ClientCore
    LEFT JOIN VT_VATScheme ON VT_ClientPack.VATSchemeID = VT_VATScheme.VATSchemeID
    LEFT JOIN CI_Entity ON VT_ClientCore.EntityCode#ClientCore = CI_Entity.EntityCode
    LEFT JOIN CI_ENTITYDETAIL ON VT_ClientCore.Entitycode#ClientCore = CI_EntityDetail.EntityCode
    LEFT JOIN SY_Address ON CI_ENTITYDETAIL.AddressID = SY_Address.AddressID
    LEFT JOIN SY_Country ON VT_ClientCore.CountryCode = SY_Country.CountryCode
    --WHERE VT_ClientCore.ClientCode = '23002'
    --AND SY_Address.PostalCode IS NOT NULL
    WHERE CI_ENTITYDETAIL.DETAILTYPE = 'AT'
    AND VT_VATScheme.VATSchemeTypeID IN (@VATSchemeType)
    AND VT_VATScheme.VATSchemeID IN (@VATSchemeID)
    GROUP BY VT_ClientCore.ClientCode,CI_Entity.Name,SY_Address.City,VT_ClientCore.VATOffice,VT_ClientCore.NatureOfBusiness,SY_Address.PostalCode,SY_Address.Address1,SY_Address.Address2,SY_Address.Address3,VT_VATScheme.SchemeName
    ,SY_Country.Description
    --VAT Scheme
    SELECT VATSchemeID,SchemeName
    FROM VT_VATScheme
    WHERE VATSchemeTypeID IN (@VATSchemeType)
    ORDER BY SchemeName

    How are you assigning the value to variable @VATSchemaType? Are you assigning multiple values? if yes, then you need to better join with the values by splitting the values. 
    The below would give an error (just for your reference)
    create table test_one(col1 int)
    Insert into test_one Values(1),(2)
    Declare @inta varchar(10) = '1,2'
    Select * From test_one where col1 in(@inta)
    Select * From test_one where col1 in(Select items From dbo.Split_BigInt(@inta,','))
    Drop table test_one
    function definition:
    create FUNCTION Split_BigInt
    @string VARCHAR(MAX),
    @delimiter CHAR(1)
    RETURNS @results TABLE
    items BigInt
    AS
    BEGIN
    DECLARE @index INT
    DECLARE @temp TABLE (
    items BigInt)
    IF @string = ''
    RETURN
    SET @string = LTRIM(RTRIM(@string))
    SELECT @index = Charindex(@delimiter, @string)
    WHILE @index <> 0
    BEGIN
    INSERT INTO @temp (items)
    VALUES (LTRIM(RTRIM(LEFT(@string, @index - 1))))
    SELECT @string = LTRIM(RTRIM(RIGHT(@string, Len(@string) - @index)))
    SELECT @index = Charindex(@delimiter, @string)
    END
    INSERT INTO @temp (items)
    VALUES (@string)
    INSERT INTO @results (items)
    SELECT items
    FROM @temp
    where
    items <> ''
    RETURN
    END

  • Conversion failed when converting the varchar value to data type int error

    Hi, I am working on a report which is off of survey information and I am using dynamic pivot on multiple columns.
    I have questions like Did you use this parking tag for more than 250 hours? If yes specify number of hours.
    and the answers could be No, 302, 279, No and so on....
    All these answers are of varchar datatype and all this data comes from a partner application where we consume this data for internal reporting.
    When I am doing dynamic pivot I get the below error.
    Error: Conversion failed when converting the varchar value 'No' to data type int.
    Query
    DECLARE @Cols1 VARCHAR(MAX), @Cols0 VARCHAR(MAX), @Total VARCHAR(MAX), @SQL VARCHAR(MAX)
    SELECT @Cols1 = STUFF((SELECT ', ' + QUOTENAME(Question) FROM Question GROUP BY Question FOR XML PATH('')),1,2,'')
    SELECT @Cols0 = (SELECT ', COALESCE(' + QUOTENAME(Question) + ',0) as ' + QUOTENAME(Question) FROM Question GROUP BY Question FOR XML PATH(''))
    SET @SQL = 'SELECT QID, QNAME' + @Cols0 + '
    FROM (SELECT QID, QNAME, ANSWERS, Question
    FROM Question) T
    PIVOT (MAX(ANSWERS) FOR Question IN ('+@Cols1+')) AS P'
    EXECUTE (@SQL)
    I am using SQL Server 2008 R2.
    Please guide me to resolve this.
    Thanks in advance..........
    Ione

    create table questions (QID int, QNAME varchar(50), ANSWERS varchar(500), Question varchar(50))
    Insert into questions values(1,'a','b','c'), (2,'a2','b2','c2')
    DECLARE @Cols1 VARCHAR(MAX), @Cols0 VARCHAR(MAX), @Total VARCHAR(MAX), @SQL VARCHAR(MAX)
    SELECT @Cols1 = STUFF((SELECT ', ' + QUOTENAME(Question) FROM Questions GROUP BY Question FOR XML PATH('')),1,2,'')
    SELECT @Cols0 = (SELECT ', COALESCE(' + QUOTENAME(Question) + ',''0'') as ' + QUOTENAME(Question) FROM Questions GROUP BY Question FOR XML PATH(''))
    SET @SQL = 'SELECT QID, QNAME' + @Cols0 + '
    FROM (SELECT QID, QNAME, ANSWERS, Question
    FROM Questions) T
    PIVOT (MAX(ANSWERS) FOR Question IN ('+@Cols1+')) AS P'
    EXECUTE (@SQL)
    drop table questions

Maybe you are looking for

  • OKKP Profit center issue

    In OKKP T code what is the impact, if we select Profit center option. Generally we have selected Projects and Cost objects. But are in CRM Implementation process, in that scenario below error we are getting. Account-based PCA not active in year 2011

  • HT203167 Music files present but iTunes can't see them

    OK, I have the unfortunate situation that all of my music files appear to be present and correct, but iTunes just shows nothing at all. I have tried all of the suggestions I can find online, including changing the Music folder using iTunes Preference

  • Where can I find the user guide for the 4th gen. ipod touch?

    Can someone tell me where I can find the user guide for the 4th gen. ipod touch? It's not on the manuals section, only the 5th gen. is.

  • N6131 - java app problem - java.io.IOException

    Hi, I need to help with the following problem - I convert e-books from TXT to the phone (my mother's 6131) using free soft Readmaniac that can take a TXT file and a font file and create a Java application. Unfortunately, my mother recently has follow

  • G60 laptop and waking from sleep

    I have an HP G60 (sorry, I do not have the exact model number handy) that has a cracked screen. I was going to try to repurpose it into an HTPC, but I do not want it to be running all the time.  I am worried about overheating.  I can set the laptop t