SQL Insert Statement Data Type Mismatch Error

I am doing a very simple web application that has a Microsoft Access database as the data source. I have been able to sucessfully create update and query statements using parameters but am having issues with an insert statement. I am using JSTL 1.1.2
The following code creates the data type mismatch error.
<sql:update
     sql="insert into tblTtoF(TFToolID,TFFeatID) values(?,?)">
        <sql:param value='$(ID}'/>
     <sql:param value='${feature}'/>
        </sql:update>The table has NUMBER as the data type for both of these fields and the variables I am feeding into it are both numbers. If I hard code the first number into the sql statement then it works. I have tried swapping the variables around and as long as the first one is hard coded the parameter for the second one works no matter which is first or second.
However I can get the following code to work, which of course leaves me vulnerable to sql injection attacks which is not really a good thing.
<sql:update>
     insert into tblTtoF(TFToolID,TFFeatID) values('<c:out value="${ID}"/>','<c:out value="${feature}"/>')
        </sql:update>So I am just looking for any suggestions as to why my first piece of code doesn't work seeing as it is the simplest of SQL statements and the most standard syntax.
Thanks

I changed it to the following
     <c:set var="featurenew" value="${0 + feature}"/>
     <c:set var="IDnew" value="${0 + param.toolID}"/>
          <sql:update
          sql="insert into tblTtoF(TFToolID,TFFeatID) values(?,?)">
          <sql:param value='$(IDnew}'/>
          <sql:param value='${featurenew}'/>
          </sql:update>And got the following error in the localhost.log
31/07/2006 09:31:41 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: SQL Exception : [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented
     at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(JdbcOdbcPreparedStatement.java:1437)
     at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(JdbcOdbcPreparedStatement.java:1072)
     at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setObject(JdbcOdbcPreparedStatement.java:1063)
     at org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.setParameters(UpdateTagSupport.java:254)
     at org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.doEndTag(UpdateTagSupport.java:156)
     at org.apache.jsp.dataUpdated_jsp._jspx_meth_sql_update_1(dataUpdated_jsp.java:975)
     at org.apache.jsp.dataUpdated_jsp._jspx_meth_c_if_0(dataUpdated_jsp.java:879)
     at org.apache.jsp.dataUpdated_jsp._jspx_meth_c_forEach_0(dataUpdated_jsp.java:680)
     at org.apache.jsp.dataUpdated_jsp._jspService(dataUpdated_jsp.java:151)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
     at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
     at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
     at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:833)
     at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
     at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1285)
     at java.lang.Thread.run(Thread.java:595)
I have also tried the following in the past with no luck
<fmt:parseNumber value="${ID}" type="number" var="IDnew"/>
AND......
<sql:query
   sql="select TFToolID from tblTtoF where TFToolID = ?"
   var="toolresults">
   <sql:param value="${ID}"/>
</sql:query>
<c:forEach var="getID" items="${toolresults.rows}">
     <c:set var="theID" value="${getID.TFToolID}"/>
</c:forEach>
AND when that didn't work, added this....
<fmt:parseNumber value="${theID}" var="IDnew"/>

Similar Messages

  • Data type mismatch when inserting into text field

    Hello all,
    Using VB script and ASP.
    I have a page that inserts into a field (casenum) in a table (clientsw) in a database. The field (casenum) in the table is data type TEXT :
    I create a recordset and then an insert statement which the following is part of:
    Code to insert the casenum into the field
    rsClients("Casenum")=Right(Date(),2) & "E-100" & rsCasenumber("countervalue")
    It inserts a number like 09E-1004500
    I then have code that takes that string and passes it to the next page as a variable
    Session("UserID")=rsClients("CASENUM")
    response.redirect "done3.asp"
    When it gets to the next page it is assigned as UserID
    Dim svuserid
    svuserid = "0"
    if (Session("UserID") <> "") then svuserid = Session("UserID")
    %>
    My information inserts into the database exactly as I want it, but when it gets to the next page I get an error that is displayed that says the following:
    Microsoft JET Database Engine error '80040e07'
    Data type mismatch in criteria expression.
    /done3.asp, line 16
    My code on the second page is as follows:
    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/connNewdatabase1.asp" -->
    <%
    Dim svuserid
    svuserid = "0"
    if (Session("UserID") <> "") then svuserid = Session("UserID")
    %>
    <%
    set rsClients = Server.CreateObject("ADODB.Recordset")
    rsClients.ActiveConnection = MM_connNewdatabase_STRING
    rsClients.Source = "SELECT *  FROM CLIENTSW WHERE CASENUM=" + Replace(svuserid, "'", "''") + "  ORDER BY CASENUM"
    rsClients.CursorType = 0
    rsClients.CursorLocation = 2
    rsClients.LockType = 3
    rsClients.Open()
    rsClients_numRows = 0
    %>
    Line 16 is the one that says rsClients.Open()
    If I take the concatenation out of rsClients("Casenum")=Right(Date(),2) & "E-100" & rsCasenumber("countervalue") and have only rsClients("Casenum")=rsCasenumber("countervalue") and change the table field to number, I don't get the "datatype mismatch error"
    What do I change to enable me to leave the above statement concatenated and insert into the table correctly and complete the stuff on the next page?

    >This is an access database, varchar is not an option for a datatype.
    Sorry. In another thread I thought you mentioned using SQL Server
    >I changed the + signed to ampersands instead and it doesn't make a difference.
    I didn't think that was the problem. I was just pointing out that it's a bad practice. If you use the '+' on two strings that can evaluate as numeric, it will actually add rather than concat them.

  • AddCurrentValue date paramater Type Mismatch Error

    Post Author: brentlaw
    CA Forum: Other
    I am using vb6 and CR XI.  I have Component "Crystal ActiveX Report Viewer Library 11.0" loaded and Reference to "Crystal Reports ActiveX Designer RunTime Library 11.0".  I can successfully use AddCurrentValue and AddDefaultValue for all values except date or datetime datatype.  Here is how I am doing it:  Assume cReport is my report object
    With cReport  For X = 1 To .ParameterFields.Count          .ParameterFields(X).ClearCurrentValueAndRange          If InStr(UCase(.ParameterFields.Item(X).Name), "BEGDATE") Or InStr(UCase(.ParameterFields.Item(X).Name), "BEGINNINGDATE") Then            If .ParameterFields(X).ValueType = crDateField Then              .ParameterFields.Item(X).AddDefaultValue (BegDate$)   '//where BegDate$ = "Date(2008,3,22)"  <TYPE MISMATCH ERROR HERE>            ElseIf .ParameterFields(X).ValueType = crDateTimeField Then              .ParameterFields.Item(X).AddDefaultValue (dtBegDate$)  '//where BegDate$ = "DateTime(2008,3,22,00,00,00)" <TYPE MISMATCH ERROR>            End If          End If  Next 'xEnd With
    I have tried many combinations of the value of BegDate$ and still I get the Type Mismatch Error.  I have run out of ideas, please help inspire me.

    Post Author: Ted Ueda
    CA Forum: Other
    Here's a snippet from working code with the RDC:Session("oRpt").ParameterFields.GetItemByName("ExampleDateParameter").AddCurrentValue(CDate("2001/Jan/02"))Session("oRpt").ParameterFields.GetItemByName("ExampleTimeParameter").AddCurrentValue(CDate("3:45:00 PM"))Session("oRpt").ParameterFields.GetItemByName("ExampleDateTimeParameter").AddCurrentValue(CDate("2001/Jan/02 3:45:00 PM"))i.e., they're using Date objects and not String.Sincerely,Ted Ueda

  • Data type mismatch problem

    Hello:
    I have an sql query that works just fine when I run it
    directly in Access but when I run it on a web site, it gives me an
    error "Data type mismatch in criteria expression".
    I am working with transactions and this is an update of a
    table within a transaction.
    Here is the code:
    con.execute "UPDATE tblWells SET API_Number='" &
    Request.Form("API_Number") & "', Well_Name='" &
    Request.Form("Well_Name") & "', Drill='" &
    Request.Form("Drill") & "', Reenter='" &
    Request.Form("Reenter") & "', horizontal='" &
    Request.Form("horizontal")& "', Duration='" &
    Request.Form("Duration") & "', OilWell='" &
    Request.Form("OilWell") & "', GasWell='" &
    Request.Form("GasWell") & "', Other='" &
    Request.Form("Other") & "', SingleZone='" &
    Request.Form("SingleZone") & "', MultipleZone='" &
    Request.Form("MultipleZone")& "', NumAcresLease='" &
    Request.Form("NumAcresLease") & "', LeaseSerialNumber='" &
    Request.Form("LeaseSerialNumber") & "', LeaseName='" &
    Request.Form("LeaseName") & "', WellNumber='" &
    Request.Form("WellNumber") & "', state='" &
    Request.Form("state") & "', county='" &
    Request.Form("county") & "', wellheadElevation='" &
    Request.Form("wellheadElevation") & "', groundElevation='"
    & Request.Form("groundElevation") & "', ProposedDepth='"
    & Request.Form("ProposedDepth") & "',
    DistanceTownPostOffice='" &
    Request.Form("DistanceTownPostOffice") & "',
    DirectionTownPostOffice='" &
    Request.Form("DirectionTownPostOffice") & "',
    Distance_Nearest_Property_Line='" &
    Request.Form("Distance_Nearest_Property_Line") & "',
    DistanceNearestWell='" & Request.Form("DistanceNearestWell")
    & "', UnitSpacing='" & Request.Form("UnitSpacing") & "'
    WHERE WellID=1"
    I can't figure why the query would work fine in Access and
    not on the webpage.
    Thanks.

    A Checkbox does not exist as a form value if it empty which
    is why your SQL
    script is failing. What you need to do is create a variable
    and then assign
    it with the value. Assuming you are using ASP then taking one
    element on
    your SQL statement
    SingleZone='" & Request.Form("SingleZone")
    you would change it to
    SingleZone = strSingleZone
    Above the actual start of your SQL statement you would define
    your variables
    and set their empty values, and then assign them to the form
    values
    Dim strSingleZone = 0
    if Request.Form("SingleZone") <> "" then
    strSingleZone = Request.Form("SingleZone")
    End if
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "zavidp" <[email protected]> wrote in
    message
    news:eo9554$dd0$[email protected]..
    > Okay, I have worked further. I have isolated the fields
    that are causing
    > trouble and they are checkbox fields.
    >
    > I have been pulling my hair out all day trying to figure
    out how to set
    > access
    > and asp so that the on/off, true/false or whatever is
    passed correctly.
    >
    > Can anyone help?
    >
    > Dave
    >

  • Data type mismatch in criteria expression. What am I not seeing??

    Once again I'm stuck! I have included the query I'm trying to run below.  I have also indicated the data types of my fields.
    <cfquery name="qGetOrders" datasource="manna_premier">
    SELECT DISTINCT Count(ID) AS CountOfID,   - number
                                 TMName,   -text
                                 Sum(Quantity) AS SumOfQuantity,   - number
                                 Count(NewExisting) AS CountOfNewExisting -number
    FROM Users, Orders, ProductOrders
    WHERE SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)#
    GROUP BY UserZone, TMName
    </cfquery>
    When run it returns this error message....
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    The error occurred in D:\Inetpub\mannapremier\zvp_report2.cfm: line 11
    9 :                     Count(NewExisting) AS CountOfNewExisting
    10 : FROM Users, Orders, ProductOrders
    11 : WHERE SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)#
    12 : GROUP BY UserZone, TMName
    13 : </cfquery>
    SQLSTATE
      22018
    SQL
       SELECT DISTINCT Count(ID) AS CountOfID, TMName, Sum(Quantity) AS SumOfQuantity, Count(NewExisting) AS CountOfNewExisting FROM Users, Orders, ProductOrders WHERE SaleDate BETWEEN {d '2009-10-01'} AND {d '2009-10-31'} GROUP BY UserZone, TMName
    VENDORERRORCODE
      -3030
    DATASOURCE
      manna_premier
    I use the where clause on several other pages and it works. I don't understand where my data type is mismatched.
    Can anyone point me in the right direction?

    4) If you indeed need to select from the 3 tables Users,
    Orders, ProductOrders, then you should qualify the columns
    names like this, Users.ID, productOrders.Quantity, and so
    on.
    You also need to join on the related columns. If you forget to do that the resultset will be a massive cartesian table (huge number of records):
    rows in Table1 * #rows in Table2 * #rows in Table3

  • Data type mismatch in criteria expression

    When i execute a sql i get the following message:
    java.sql.QDLExeption.......Data type mismatch in criteria expression...
    I use MS access.
    I use java.sql.Date to this format 04-09-2003
    I use boolean
    Is the date format correct?
    Is the boolean format correct?
    I try to debug for 3 hours and i didn't succeed..
    Thanks for any responses

    Try a couple of things:
    (1) Make sure that your Access database column type is Date for the columns you think it should be. Should the boolean column be type yes/no in Access? I'm not 100% sure, but that's my guess.
    (2) Use PreparedStatement, not Statement, if you aren't already. Set the variable values in your SQL using the setXXX() methods in PreparedStatement. That will make sure that all conversions are done properly.
    MOD

  • INSERT/UPDATE date type

    I'm using an Oracle 816 and Java 2.
    There is no problem with retrieving data from the tables. My problem is "INSERT date".
    Code snip:
    (java.util.)Date dtToday = new Date();
    String strSQL = "INSERT INTO MY_DB.TABLE1 " +
    "(COLUMN1, COLUMN2) VALUES (\"bluh\", " +
    dtToday + ")";
    myStmt.executeUpdate(strSQL);
    Would you please tell me what is the right way to insert a date type (any from java.util.Date, java.sql.Date, or oracle..DATE) to an Oracle 816 table that has a date column.
    Thank you very much in advance.
    Robin Luo

    Try to use prepared statement:
    PreparedStatement pstmt =
    conn.prepareStatement ("insert into TABLE1(COLUMN1, COLUMN2) values (?, ?)");
    pstmt.setString (1, "bluh");
    pstmt.setDate (2, dtToday);
    pstmt.execute ();
    null

  • Help its really urgent.....Data type mismatch in criteria expression.

    hello everyone....
    I m trying to retrive an int value from Access database with query
    String query = "SELECT * FROM M_PROCESS WHERE PROCESS_NAME = '"+selected_process+"' ";
    Here selected_process is the string retrived from a JSP page using request.getparameter and it may retrive value with multiple spaces in it.
    i m able to retrive selected_process correctlly but when i call another servlet method to execute query with statement
    ResultSet rs = dbcon.execQuery(query);
    I get an error
    Error in connection in execution[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    can anyone help.....
    note: the datatype of PROCESS_NAME is TEXT . dbcon is the object of servlet connection manager which is responsible for connection establishment and query execution.

    Hi Nix,
    If its an Interger value use "+xxxx+" if string then use ' " ++"'
    or else try to convert the string value to interger...
    it will work

  • Generate SQL Insert Statements

    Hello,
    I am testing generating insert statements for which I have a function which will return a sql statement.
    This sql statement when I execute would results as sql insert statements.
    What I am trying to acheive through a procedure is when I execute function, the result I would like to execute automatically and then the second sql I would like to store to a control file or sql file.
    How can I acheive this?
    Any help is very helpful
    Regards
    Edited by: user20090209 on Aug 20, 2009 11:34 AM

    Here is the function to generate sql
    CREATE OR REPLACE function insert_sql(v_table_name varchar2)
    return varchar2 as
    b_found boolean := false;
    v varchar2(32000);
    v1 varchar2(32000);
    v2 varchar2(32000);
    begin
    for s in (
    select *
    from all_tables
    where table_name=upper(v_table_name)
    --and owner=upper(v_owner)
    ) loop
    b_found := true;
    for ss in (
    select *
    from all_tab_columns
    where table_name = s.table_name
    order by column_id
    ) loop
    if ss.data_type='NUMBER' then
    v1:=v1||','||ss.column_name;
    v2:=v2||',''''''||to_char('||ss.column_name||')||''''''';
    end if;
    if ss.data_type in ('VARCHAR2','CHAR') then
    v1:=v1||','||ss.column_name;
    v2:=v2||',''''''||replace(replace('||ss.column_name||','''''''',''''''''''''),''&'','''')||''''''';
    end if;
    if ss.data_type='DATE' then
    v1:=v1||','||ss.column_name;
    v2:=v2||',to_date(''''''||to_char('||ss.column_name||',''dd.mm.yyyy hh:mi:ss'')||'''''',''''dd.mm.yyyy hh:mi:ss'''')';
    end if;
    end loop;
    v:='select ''insert into '||s.table_name||' (';
    v:=v||substr(v1,2,9999)||') '||chr(10)||' values ('||substr(v2,2,9999)||'); '' txt from '||s.table_name;
    end loop;
    if not b_found then
    v:='- Table ' || v_table_name || ' not found';
    else
    v:=v;
    end if;
    return v;
    end;
    /And I am calling like
    CREATE OR REPLACE PROCEDURE test_gen_script_exec IS
    type v_ref_cur is REF CURSOR;
    v_ref_cur_var v_ref_cur;
    v_temp_sql VARCHAR2(4000);
    v_sql varchar2(4000);
    begin
    v_sql := insert_sql('table_name');--change here
    open v_ref_cur_var for v_sql;
    loop
    fetch v_ref_cur_var into v_temp_sql;
    exit when v_ref_cur_var%notfound;
    execute immediate v_temp_sql;
    end loop;
    close v_ref_cur_var;
    end;
    /Edited by: user20090209 on Aug 20, 2009 1:24 PM

  • How to solve the "type mismatch" error in jCOM early binding program?

    I got a "type mismatch" error jCOM early binding program.
    I use the VB as the jCOM client to access the EJB deployed on WLS7. While using the
    object parameter like "java.lang.Integer" in EJB method call, I got that error message
    and my VB client had to be stopped?
    The same situation, the VB program work perfect when using the "int" as the parameter.
    And I try to instance the "myTLB.JavaLangInteger" in my VB program, but how ? The
    "New", "CreateObject" and "GetObject" all failure, I don't know what to do next ???

    Hi,
    This problem Could happen when you referesh quality or test system.
    Your delta setup for the related master and transaction data needs to be reinit.
    What happens is when you init. the delta and subsequent delta is all maintained in your source system
    please check Notes 852443,424848,834229
    Hope this helps
    Thanks
    Teja
    Message was edited by:
            Teja badugu

  • RowSet Column Type Mismatch Error

    Hi,
    I am using SOA 11g,
    JDeveloper 11.1.1.3.0
    BPEL, SOA 11g, DB2 Stored procedure,
    In a BPEL service I am getting this error while invoking a DB2 Stored procedure with Strong XSD.
    while running I am getting this error message. This error message while invoking DB2 stored procedure, both XSD are identical. Input to service & input to DB adapter.
    java.lang.Exception: oracle.sysman.emSDK.webservices.wsdlapi.SoapTestException: Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'dba' failed due to: RowSet Column Type Mismatch Error. The SQL type in the XSD (CHARACTER) does not match the SQL type in the RowSet (VARCHAR) for column LONGITEM of parameter RowSet. This procedure returns a RowSet which could in theory return any arbitrary result. However you chose at design time to generate a single strongly typed XSD describing this result set in all cases, based on a test execution of the stored procedure. This makes later XML transforms easier. You may have also edited the XSD directly. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
    -CD

    Hi CD,
    maybe if your strong XSD contains db:type="CHAR", you could try to change it to "VARCHAR" instead.
    HTH,
    Steve

  • Problem Uploading Mapping to FDM in 11.1.2.1, Receiving Type Mismatch Error

    Has the mapping format changed in system 11 changed from system 9?
    One of my users who is responsible for uploading maps is trying to upload his Excel mapping document (which he used in version 9) into FDM 11.1.2.1 and is receiving a Type mismatch error.
    Error Log
    ERROR
    Code: 13
    Description: Type mismatch Row=3 SrcDec=(000-General Cash) TargKey=(10000) ChangeSign=(False) WhereClauseType=(Error 2029)
    Procedure: clsUtility.mRecordsetFromExcel
    Component: upsWDataWindowDM
    Version: 1112
    Thread: 185652
    Any assistance would be appreciated.

    Well, as you can see I am having a bit of trouble with this user. I finally got him to send me the files he was attempting to load and not the test file. I received the error.
    Here is the only log entry for this error:
    ** Begin FDM Runtime Error Log Entry [2011-08-12 16:44:41] **
    ERROR:
    Code............................................. 13
    Description...................................... Type mismatch
    Row=3 SrcDesc=(000-General Cash) TargKey=(10000) ChangeSign=(False) WhereClauseType=(Error 2029)
    Procedure........................................ clsUtility.mRecordsetFromExcel
    Component........................................ upsWDataWindowDM
    Version.......................................... 1112
    Thread........................................... 13988
    IDENTIFICATION:
    User............................................. <withheld>
    Computer Name.................................... <withheld>
    App Name......................................... <withheld>
    Client App....................................... WebClient
    CONNECTION:
    Provider......................................... SQLOLEDB
    Data Server...................................... <withheld>
    Database Name.................................... <withheld>
    Trusted Connect.................................. False
    Connect Status.. Connection Open
    GLOBALS:
    Location......................................... <withheld>
    Location ID...................................... 873
    Location Seg..................................... 19
    Category......................................... WLActual
    Category ID...................................... 14
    Period........................................... Jul - 2011
    Period ID........................................ 7/31/2011
    POV Local........................................ False
    Language......................................... 1033
    User Level....................................... 1
    All Partitions................................... True
    Is Auditor....................................... False

  • CAST Not working for me - Arithmetic overflow error converting int to data type numeric - error

    GPM is DECIMAL(5,2)
    PRICE is DECIMAL(11,4)
    COST is DECIMAL(7,2)
    Trying to update the Gross Profit Margin % field and I keep getting the "Arithmetic overflow error converting int to data type numeric" error.
    UPDATE SMEMODETAIL SET SMD_GPM = (SMD_PRICE-SMD_COST) / SMD_PRICE * 100
    FROM SMEMODETAIL WHERE SMD_PRICE<>0 AND SMD_QUANTITY<>0
    Example record:
    SMD_PRICE    SMD_COST    GPM%
    1.8500            1.62                12.4324324324324300
    I added cast and I still get the error.
    How do I format to get this to work?
    Thanks!

    Hi GBerthume,
    The error is caused by some value such as 1000.01 of the expression (SMD_PRICE-SMD_COST) / SMD_PRICE * 100 exceeds the
    precision of the column(DECIMAL(5,2)). The example data doesn't cause the overflow error for the value of the expression is 12.43 which is in the scope of DECIMAL(5,2).
    USE TestDB
    CREATE TABLE SMEMODETAIL
    SMD_PRICE DECIMAL(11,4),
    SMD_COST DECIMAL(7,2),
    SMD_GPM DECIMAL(5,2)
    INSERT INTO SMEMODETAIL(SMD_PRICE,SMD_COST) SELECT 1.8500,1.62
    UPDATE SMEMODETAIL SET SMD_GPM = (SMD_PRICE-SMD_COST) / SMD_PRICE * 100
    FROM SMEMODETAIL WHERE SMD_PRICE<>0-- AND SMD_QUANTITY<>0
    SELECT * FROM SMEMODETAIL
    DROP TABLE SMEMODETAIL
    The solution of your case can be either scale the DECIMAL(5,2) or follow the suggestion in Scott_morris-ga's to check and fix your data.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Data type mismatch while writing a code in BADi

    Hi Experts,
    While writing a code in BADi, I am facing data type mismatch.
    Scenario:
    I have created the Infospoke based on one ODS and inside BADi i am looking up the other ODS fields.
    Two ODS's having 4 common key fields but one key field having the data type mismatch.
    While selecting the data from other ODS table in where condition it's giving the error data type mismatch.
    Could you please advice the same please.
    Thanks.
    Gana.

    Any update please....
    Thanks in advance.
    Edited by: Gananadha Lenka on Jun 18, 2010 1:57 PM

  • Data Type mismatch in for all entries.

    Dear Friends,
    I have a problem...please advice me for that..... I m using code as following...actually the isse is when ever i am using
        WHERE docno = it_j_1iexchdr-rdoc (along with FOR ALL ENTRIES IN) the error is occured data type mismatch.
    becoz DOCNO is field of(j_1iexchdr) and RDOC is a character field of same table...but i want to get reference data..so i need to compare both field...u can undersdand my requirement in following coding.. Error line is denoted by (<----
      DATA: BEGIN OF it_j_1iexchdr OCCURS 0,
            bukrs LIKE j_1iexchdr-bukrs,               " Company Code.
            exnum LIKE j_1iexchdr-exnum,               " Excise Invoice No.
            exdat LIKE j_1iexchdr-exdat,               " Excise Invoice Dt.
            kunag LIKE j_1iexchdr-kunag,               " Sold-to-party
            kunwe LIKE j_1iexchdr-kunwe,               " Ship-to-party
            rdoc  LIKE j_1iexchdr-rdoc,
           rdoc  TYPE j_1iexchdr-docno,
            addldata1 LIKE j_1iexchdr-addldata1,       " Reason for Issueing Excise Invoice
            exbed LIKE j_1iexchdr-exbed,               " Excise Duty
            ecs   LIKE j_1iexchdr-ecs,                          " 2%Cess
            exaddtax1 LIKE j_1iexchdr-exaddtax1,       " Shec
            trntyp LIKE j_1iexchdr-trntyp,                   " OTHR
            END OF it_j_1iexchdr.
      DATA: wa_j_1iexchdr LIKE it_j_1iexchdr.
      DATA: BEGIN OF it_j_1iexchdr1 OCCURS 0,
            trntyp LIKE j_1iexchdr-trntyp,
           docno LIKE j_1iexchdr-rdoc,
            rdoc LIKE j_1iexchdr-rdoc,
            END OF it_j_1iexchdr1.
      DATA: wa_j_1iexchdr1 LIKE it_j_1iexchdr1.
    SELECT bukrs exnum exdat kunag kunwe rdoc
             addldata1 exbed ecs exaddtax1 trntyp
      FROM j_1iexchdr
      INTO CORRESPONDING FIELDS OF TABLE it_j_1iexchdr
      WHERE  bukrs IN v_bukrs
      AND   exdat IN v_exdat
      AND   trntyp = 'OTHR'.
    IF it_j_1iexchdr[] IS NOT INITIAL.
         SELECT trntyp docno rdoc
        FROM  j_1iexchdr
        INTO CORRESPONDING FIELDS OF table it_j_1iexchdr1
        FOR ALL ENTRIES IN it_j_1iexchdr
        WHERE docno = it_j_1iexchdr-rdoc  <----
    I
        AND   trntyp = 'DLFC'.
      ENDIF.
    Pl help me as soon as possible...
    Thanks & Regards,
    Swapnika Panse

    Hi,
    In table j_1iexchdr, there are two fields
    RDOC     J_1IRDOC1     CHAR     10      Reference Document 1
    DOCNO     J_1IDOCNO     NUMC     10      Internal Excise Document Number
    RDOC is of character type and DOCNO is of numeric type.
    Your declaration for fields is :
    docno LIKE j_1iexchdr-rdoc,
    rdoc LIKE j_1iexchdr-rdoc,
    And in the select query you are trying to fetch docno which is of type j_1iexchdr-rdoc. SO, change your declaration from
    docno LIKE j_1iexchdr-rdoc,
    to
    docno LIKE j_1iexchdr-docno,
    This should solve your problem.
    Thanks,
    Archana

Maybe you are looking for

  • HT5070 I bought a tv series but only getting the first episode

    I got charged for the whole season but only have one episode available to me and it's not showing up in my recently purchased file!

  • Cannot find fields in LSMW

    hi abap gurus, i need your help, this is a Purchase order conversion program, from4.7 to ECC 6.0, the iput is an excel file which contains the extracted data from 4.7 the structure of the iput file would be Purchase Req Number  from ECC 6.0  ( EBAN-B

  • How to Reset or Erase content on iPod....I am selling mine...

    Now that I have a video iPod, I don't need the original Classic version anymore. A co-worker would like to buy it from me. However I noticed that I still have contacts and other personal info in there along with over 1,000 songs. What is the procedur

  • Problems installing lightroom 4 on mac running leopard osx 10.5.8

    When I insert disc, I can open the disc, showing the lightroom 4 package, and the readme file. When I double click the package, nothing happens. When I open the installer, and click on the disc for lightroom 4, nothing happens. Help?

  • Backlight on Keyboard and

    Hi All! I've got a couple of questions about the "backlight" on the Curve 83330. I notice that at certain intervals the light on the QWERTY keyboard automatically goes out. What is the easiest way to either return the light back to it's normal state,