Sql insert single qoute ' problem

I have problem when insert string that hv single quote.
Can anyone help me on this...
query = "INSERT INTO lexicon VALUES ( " + id + ", '" + lex + "')";
s.executeUpdate(query);where lex is ambassador's.
Below is the error:
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's')' at line 1

Based on your coding I assume that lex is a string variable holding the value ambassador's. So that your query variable would be like this
INSERT INTO lexicon VALUES ( 123 , 'ambassador's' )
did you notice that your second value does not closed properly. to resolve this try to suppress the codes which is inside your lex value. Lets assign
lex = "ambassador''s"; //two single quotes between r and s

Similar Messages

  • Help with sql insert single quotes

    String insert = "INSERT INTO users(firstName, lastName, emailAdd, password) VALUES("+ firstNameForm + "," + lastNameForm + "," + emailForm + "," + passwordForm + ")";
    Statement stmt = conn.createStatement();
         int ResultSet = stmt.executeUpdate(insert);
    I have that sql insert statment in my servlet the servlet compiles fine but does not insert into the users table, i have been told that it is something to do with single quotes in sql statement, can anybody help me out?

    Or can i change my sql table is there a autonumber which would increase everytime this servlet runs?make your field autoincrement :-)
    example
    ALTER TABLE `users` CHANGE `user_id` `user_id` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT To insert record in the table.
    example:
    you have a table test and got two fields,
    id = (INT) autoincrement
    name = VARCHAR / TEXT etc.
    to insert data to the table test try something like this:
    String SQLStatement = "INSERT INTO test";
    SQLStatement += "(name)";
    SQLStatement += " VALUES (?)";
    statement = Conn.prepareStatement(SQLStatement);
    statement.setString(1, "Duke");
    statement.executeUpdate();
    statement.close();
    Conn.close();Note we dont provide the field for id on our sql statement since it is set as auto-increment ;-)
    regards,
    Message was edited by:
    jie2ee

  • Export "SQL Insert" problem

    Hello to everybody,
    I'm using SQL Developer 1.0.0.15.57 in an Italian Windows XP Professional SP2.
    I'm exporting a table as "SQL Insert" and I have the following problem: the exported INSERT instruction contains, i.e., 123,45 instead of 123.45 so, running the INSERT, Oracle 10 tells me too much values were given because
    Value1, 123,45, Value2, ...
    is wrong: it should be
    Value1, 123.45, Value2, ...
    I think this is a problem of the Internation settings (in Italy we use , as decimal separator instead of the . ). Does anybody know how to solve this?
    For the moment I have changed my Internal Settings with USA and, after arestart, this is fixed. However now there is another less heavy problem: the dates are written in English like to_date('01-JAN-06', ... instead of to_date('01-GEN-06', ... but I can fix it with a search&replace function.
    Thank you in advance
    Andrea

    Hello. I'm trying to find a solution for this too. In Venezuela we also use , as decimal separator. Has anybody found a solution for this? It is absolutly necesary to change the international settings of my pc?
    Thanks!
    Message was edited by:
    JeanK

  • SQL INSERT problem - help please

    Hello,
    I'm having a problem with INSERT statement.
    There is a "ShowFinal.jsp" page, which is a list of candidates who selected from the second
    interview. The user picked some candidates from the list and conduct the 3rd interview. After
    he check suitable candidates(who are selected from the 3rd interview) from the list , enter
    basic salary for every selected candidate, enter date of interview and finally submit the form.
    These data should be save into these tables.
    FinalSelect(nicNo,date)
    EmpSalary(nicNo,basicSal)
    In this "ShowFinal.jsp" page, it validates the following conditions using JavaScript.
    1) If the user submit the form without checking at least one checkbox, then the system should be
    display an alert message ("Please select at least one candidate").
    2) If the user submit the form without entering the basic salary of that candidate which was
    checked, then the system should be display an alert message ("Please enter basic salary").
    These are working well. But my problem is how to wrote the "AddNewFinal.jsp" page to save these
    data into the db.
    Here is my code which I have wrote. But it points an error.
    "AddNewFinal.jsp"
    String interviewDate = request.getParameter("date");
    String[] value = request.getParameterValues("ChkNicno");
    String[] bs = request.getParameterValues("basicSal");
    String sql ="INSERT INTO finalselect (nicNo,date) VALUES(?,?)";
    String sql2 ="INSERT INTO EmpSalary (nicNo,basicSal) VALUES(?,?)";
    for(int i=0; i < value.length; i++){
         String temp = value;     
         for(int x=0; x < bs.length; x++){
              String basic = bs[x];
              pstmt2 = connection.prepareStatement(sql2);
              pstmt2.setString(1, temp);
              pstmt2.setString(2, basic);
              int RowCount1= pstmt2.executeUpdate();
         pstmt1 = connection.prepareStatement(sql);
         pstmt1.setString(1, temp);
         pstmt1.setString(2, interviewDate);
         int RowCount= pstmt1.executeUpdate();
    Here is the code for "ShowFinal.jsp".
    <form name="ShowFinal" method="POST" action="AddNewFinal.jsp" onsubmit="return checkEmpty() &&
    ValidateDate();">
    <%--  Loop through the list and print each item --%>
    <%
         int iCounter = 0; //counter for incremental value
         while (igroups.hasNext()) {
              Selection s = (Selection) igroups.next();
              iCounter+=1; //increment
    %>
    <tr>
         <td style="background-color:ivory" noWrap width="20">
         <input type="checkbox" name="<%= "ChkNicno" + iCounter %>"      
    value="<%=s.getNicno()%>"></td>
            <td style="background-color:ivory" noWrap width="39">
                 <%= s.getNicno() %>  </td>
         <td style="background-color:ivory" noWrap width="174">
              <input type="text" name="<%= "basicSal" + iCounter %>" size="10"> </td>
    </tr>
    <%
    %>
    Date of interview<input type="text" name="date" size="17"></td>
    <input type="submit" value="APPROVE CANDIDATE" name="B1" style="border: 1px solid #0000FF">
    </form>........................................................
    Here is the error generated by TOMCAT.
    root cause
    java.lang.NullPointerException
         at org.apache.jsp.AddNewFinal_jsp._jspService(AddNewFinal_jsp.java:70)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
    I have goto the file "AddNewFinal_jsp.java". The line 70 points to the following line.
    for(int i=0; i < value.length; i++){ [/b]
    Please can someone help me to solve this problem? Please help me to do this task.
    Thanks.

    Hi Casabianca ,
    It is clearly that your problem is not on the database end, more like a servlet/jsp issue.
    I will not comment on the javascript portion, but rather the 2 jsps.
    a simple way to trace what's go wrong is to check the final result (the html code) of the first jsp (showFinal.jsp), and compare against what is expected by the 2nd jsp (AddNewFinal.jsp). Most browser do provide "view source" on the page visited.
    the following code
    <input type="checkbox" name="<%= "ChkNicno" + iCounter %>" value="<%=s.getNicno() %>">
    <input type="text" name="<%= "basicSal" + iCounter %>"
    would likely to be "translated" to html code something as follow:
    <input type="checkbox" name=""ChkNicno0" value="nicNo>">
    <input type="text" name="basicSal0">
    the original code in "AddNewFinal.jsp" using
    request.getParameterValues("ChkNicno");
    which looking for a none exist http request parameter (sent as "ChkNicno0",etc but look for "ChkNicno"), which has explained before.
    the second attempt to use String[] value = request.getParameterValues("ChkNicno" + iCounter); give Cannot resolove symbol :iCounter. because iCounter never defined in the 2nd jsp!
    Most of the error message do give clue to cause of error... : )
    not too sure on your intension, assume you wish to update only those selected (checked) row to db.
    some suggestions:
    1) <input type="text" name="ChkNicno" size="10"> </td>...
    <input type="text" name="basicSal" size="10"> instead.
    then use javascript to based on checked element index (refer to javascript spec for more details), for those index not checked, clear off the correspond index "basicSal" field value.
    e.g. ChkNicno[1] is not checked, empty basicSal[1] value before submission.
    This will give us only selected rows values.
    2) retain the code
    String[] value = request.getParameterValues("ChkNicno");
    String[] bs = request.getParameterValues("basicSal");at 2nd jsp, as now the http request will pass parameters using "ChkNicno" and "basicSal".
    3) some change to the code for optimization
    for(int i=0; i < value.length; i++){
         String temp = value;     
         for(int x=0; x < bs.length; x++){
              String basic = bs[x];
              pstmt2 = connection.prepareStatement(sql2);
              pstmt2.setString(1, temp);
              pstmt2.setString(2, basic);
              int RowCount1= pstmt2.executeUpdate();
         pstmt1 = connection.prepareStatement(sql);
         pstmt1.setString(1, temp);
         pstmt1.setString(2, interviewDate);
         int RowCount= pstmt1.executeUpdate();
    to
    pstmt1 = connection.prepareStatement(sql);
    pstmt2 = connection.prepareStatement(sql2);
    for(int i=0; i < value.length; i++){
         String temp = value;     
         for(int x=0; x < bs.length; x++){
              String basic = bs[x];
              pstmt2.setString(1, temp);
              pstmt2.setString(2, basic);
              int RowCount1= pstmt2.executeUpdate();
         pstmt1.setString(1, temp);
         pstmt1.setString(2, interviewDate);
         int RowCount= pstmt1.executeUpdate();
    preparestatement created once should be sufficient as we do not change the sql statement throughout the loop.
    there are better solutions out there, this just some ideas and suggestions.Do try out if you wish.
    Hope it helps. : )

  • How to insert single colon xml text in the xml table

    Dear Sir,
    how to insert special characters like single colon text example (don't) xml text in to the xml table
    please see the following example its giving me error quoted string is not ended properly
    SQL> insert into ftr_ctl values (1,
    2 xmltype('<po:root xmlns:po="http://www.oracle.com/FC.xsd"
    3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4 xsi:schemaLocation="http://www.oracle.com/FC.xsd
    5 http://www.oracle.com/FC.xsd">
    6 <row>
    7 <UniqueIdentifier>urn:x-gcs:def:featureType:GFDD::FT_DFDD_100565</UniqueIdentifier>
    8 <AlphaCode>ZB032</AlphaCode>
    9 <Name>Baseline Point</Name>
    10 <Status>Submitted</Status>
    11 <Definition>A location that serves as a point on, and which partially defines a segment
    of, a national boundary baseline.</Definition>
    12 <Description>May be monumented or unmonumented. A national boundary baseline is used fo
    r defining the landward edge or margin of a nation's various contiguous zones such as the 3 and 12 n
    autical mile limits and the Exclusive Economic Zone (EEZ).</Description>
    13 </row>
    14 </po:root>'));
    ERROR:
    ORA-01756: quoted string not properly terminated
    how to solve single quotation like (nation's) in xml data insertion
    please give me reply as soon as possible
    Thanks
    Kabeer

    Hi,
    Use &#x7B;code} tags to post formatted code on the forum.
    That way, your code will be more readable for everyone, and more importantly here, everyone will be able to clearly see what's bothering you :
    &apos;sThe single quote was encoded with the character entity reference "&amp;apos;".
    The conversion is not mandatory but it happens Oracle is doing it in this case.
    It shouldn't be a problem though.
    If you want to extract the value afterwards, it'll come as expected :
    SQL> create table ftr_ctl (id number, doc xmltype);
    Table created
    SQL> insert into ftr_ctl values (1,
      2  xmltype('<po:root xmlns:po="http://www.oracle.com/FC.xsd"
      3  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      4  xsi:schemaLocation="http://www.oracle.com/FC.xsd
      5  http://www.oracle.com/FC.xsd">
      6  <row>
      7  <UniqueIdentifier>urn:x-gcs:def:featureType:GFDD::FT_DFDD_100565</UniqueIdentifier>
      8  <AlphaCode>ZB032</AlphaCode>
      9  <Name>Baseline Point</Name>
    10  <Status>Submitted</Status>
    11  <Definition>A location that serves as a point on, and which partially defines a segment of, a national boundary baseline.</Definition>
    12  <Description>May be monumented or unmonumented. A national boundary baseline is used for defining the landward edge or margin of a nation''s various contiguous zones such as the 3 and 12 nautical mile limits and the Exclusive Economic Zone (EEZ).</Description>
    13  <Alias xsi:nil="true"></Alias>
    14  <SourceItemIdentifier>100565</SourceItemIdentifier>
    15  <SourceReference>DGIWG DFDD BL 2011-1.00</SourceReference>
    16  <SourceURL>https://www.dgiwg.org/FAD/fdd/view?i=100565</SourceURL>
    17  </row>
    18  </po:root>'));
    1 row inserted
    SQL> select extractvalue(doc, '/po:root/row/Description','xmlns:po="http://www.oracle.com/FC.xsd"')
      2  from ftr_ctl
      3  where id = 1
      4  ;
    EXTRACTVALUE(DOC,'/PO:ROOT/ROW/DESCRIPTION','XMLNS:PO="HTTP://WWW.ORACLE.COM/FC.
    May be monumented or unmonumented. A national boundary baseline is used for defi
    ning the landward edge or margin of a nation's various contiguous zones such as
    the 3 and 12 nautical mile limits and the Exclusive Economic Zone (EEZ).
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How I can make SQL Insert file on schedule

    Dear Community Members;
    Hope all you will be perfect. I required your urgent response on my query. I want to make an SQL Insert file, means I want to insert data from query in one table and after that, the data export in an SQL file as a SQL Insert file.
    All these things want to do on schedule not manually.
    Can anyone help and guide me how I can do it?

    Dear Members;
    Actually, we are working on two different applications, like sale and account. Now we want to post sale information in account system without any DBLink, for that I want to make a file where my data store in SQL Insert Statement format on scheduling, means I want to create a procedure which create this file on scheduling. After that same as I want to create a procedure in other system for read that file and execute. Now I have been found Oracle functionality but still I am facing a problem. The problem is that my procedure create a file with a single record not the all fetched record. My Procedure is as:
    DECLARE
      fileHandler UTL_FILE.FILE_TYPE;
      INSERT1 VARCHAR2(200);
      INSERT2 VARCHAR2(200);
      cursor c1 is
        select T.QTY, T.SLIP_NO, T.STORE_NO, T.Item_Code
        from test t
        where T.STORE_NO = 1;
    BEGIN
        for cur_rec in c1 loop
        INSERT1 := 'INSERT INTO TEST_2(Item_Code,STORE_NO,QTY,SLIP_NO) VALUES(';
        INSERT2 := INSERT1||CUR_REC.Item_Code||','||CUR_REC.STORE_NO||','||CUR_REC.QTY||','||CUR_REC.SLIP_NO||')' ;
      fileHandler := UTL_FILE.FOPEN('E:\Oracle\admin\udump', 'test_file2.SQL', 'W');
      --UTL_FILE.PUTF(fileHandler, 'Writing TO a file\n');
      UTL_FILE.PUTF(fileHandler, INSERT2);
      UTL_FILE.PUTF(fileHandler, '\n commit;');
      UTL_FILE.FCLOSE(fileHandler);
      END LOOP;
    EXCEPTION
      WHEN utl_file.invalid_path THEN
         raise_application_error(-20000, 'ERROR: Invalid PATH FOR file.');
    END;
    Please suggest/guide me where I am doing something wrong or missing. I'll thankful for your help.

  • To insert single quote in a varchar2 field

    hi guys,
    i am facing a simple problem, can any one of you help me in this regard. the problem is i am unable to insert a single quote in a varchar2 field like
    SQL> DESC EMP
    Name Null? Type
    EMPNO NOT NULL NUMBER(4)
    ENAME VARCHAR2(10)
    JOB VARCHAR2(9)
    MGR NUMBER(4)
    HIREDATE DATE
    SAL NUMBER(7,2)
    COMM NUMBER(7,2)
    DEPTNO NUMBER(2)
    SQL> INSERT INTO EMP (EMPNO, ENAME) VALUES (100, 'Mc'Aure') ;
    ERROR:
    ORA-01756: quoted string not properly terminated
    oracle takes ' as the delimiters for identifying the word. in my case the name itself contains a single quote which is to be inserted. how to insert the single quote
    i want to insert it from asp coding and also from sql plus 8.0.
    advanced thanks
    ananth

    If you use a ' in a varchar2, it must be marked with a second '.
    In your case:
    SQL> INSERT INTO EMP (EMPNO, ENAME) VALUES
    (100, 'Mc''Aure') ;
    null

  • How to insert single quotation marks

    Hi folks!
    I'm having problem with inserting single quotation marks (').
    I know this could be easily solved but I'm not sure what the best solution is.
    Example
    updatePackingMethod("That's it");
    will throw a sql exception:
    Syntax error (missing operator) in query expression ''that's it'
    my function is written like this
    public boolean updatePackingMethod(String packName, int id){
    String sql="Update PackMethod set PackMethodName='"+packName+"' where Id ="+ id;
    try {
    Statement stmt=conn.createStatement();
    int result=stmt.executeUpdate(sql);
    if(result>0)
    return true;
    catch (SQLException ex) {
    ex.printStackTrace();
    error.setError(ex.getMessage);
    return false;
    Any?
    /Filip

    public boolean updatePackingMethod(String packName, int id){
    String sql=" Update PackMethod set PackMethodName= ? where Id = ? ";
    PreparedStatement pstmt = null;
    try {
    pstmt = conn.prepareStatement( sql );
    // pstmt.setXXX( index, paramValue );
    // where XXX is datatype of parameter
    // index is the Nth ? (question mark) in the sql
    // paramValue is the value to be used instead of ?
    pstmt.setString( 1, packName );
    pstmt.setInt( 2, id );
    int result=pstmt.executeUpdate( );
    if(result>0)
    return true;
    catch (SQLException ex) {
    ex.printStackTrace();
    error.setError(ex.getMessage);
    } finally {
    if( pstmt != null ) pstmt.close();
    return false;

  • SQL insert statement in java with Excel file

    Dear all,
    I wrote a program is as the follow:
    import java.io.*;
    import java.sql.*;
    public class handleExcel
         Connection con = null;
         Statement stmnt = null;
         public handleExcel()
              String excel = "C:\\EGS\\app_files\\info_update_form_exported_data.xls";
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   String str="jdbc:odbc:DRIVER=Microsoft Excel Driver (*.xls);DBQ=" + excel + ";";
         String sql = "insert into [Sheet1$] (Name, Age, Test1, Test2, Test3) values ('mary','16','aa','bb','vv')";
                   con = DriverManager.getConnection(str, "", "");
                   stmnt = con.createStatement();
                   stmnt.executeUpdate(sql);
              catch(Exception e)
                   System.out.println("con is error!!");
                   e.printStackTrace();
         public static void main(String[] args)
              handleExcel TestHpc = new handleExcel();
    But when I run it, the error is as the follow:
    java.sql.SQLException: [Microsoft][ODBC Excel Driver]
         at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
         at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
         at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
         at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
         at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
         at hk.gov.edb.util.handleExcel.<init>(handleExcel.java:31)
         at hk.gov.edb.util.handleExcel.main(handleExcel.java:97)
    Please help me to solve this problem. Thank you so much for your help!
    Regards,
    kzyo

    Hi
    You can use the[b] jakarta POI api in order to read/write Excel file from java. Pure Java, no drivers nedeed.
    I tested and ok.
    Hope this helps

  • Apostrophe in a String bombs a SQL insert

    I am having an issue with a Customer String parameter that is being used in a SQL INSERT. The customer name may from time to time have an apostrophe in it that causes our SQL INSERT to bomb on a missing comma error. I have tried to do this two separate ways:
    1)
    String query = "INSERT into CUSTOMER VALUES(" + account[0].custAcctNbr + ",'" + account[0].companyNm + "'," +
                   "'IN',null," + salesPerson[0].salespersonID + "," + "null,null,null,null,null," +
                   "null,null,null,null,null,null,null,null,null)";
    This works until an apostrophe is in the companyNm varaiable.
    2)
         PreparedStatement insertCustomer = bcc_conn_cust.prepareStatement(
         "INSERT into CUSTOMER VALUES(?,?,?,null,?,null,null,null,null,null,null,null,null,null,null,null,null,null,null");
         insertCustomer.setInt(1,Integer.parseInt(account[0].custAcctNbr));
         insertCustomer.setString(2,account[0].companyNm);
         insertCustomer.setString(3,"IN");
         insertCustomer.setInt(4,salesPerson[0].salespersonID);
         insertCustomer.executeUpdate();
    This also works when there is no apostrophe. However both bomb when it is present. Is there anyway to get around this, short of parsing a company name every single time we insert a new customer?

    Do you have any idea why this is not working? yes, whatever driver you are using isn't implementing this properly.
    variable I am using is a String variable, that has a
    value of Bates' Brownies. According to all I read, it
    seems I have used the Prepared Statement correctly but
    it is giving me that missing comma error. I would
    really rather not have to search every single company
    name as it is entered.well unless you can either find another driver or fix the one you've
    got i can't see what else you can do...
    here is some code to help you along with that.
    private String replaceQuotes(String toReplace){
      StringBuffer buff = new StringBuffer(toReplace);
      for(int i=0;i<buff.length();i++){
        if(buff.charAt(i)=='\''){
          buff.insert(i,'\'');
          i++;
      return buff.toString();

  • SQL insert with select statement having strange results

    So I have the below sql (edited a bit). Now here's the problem.
    I can run the select statement just fine, i get 48 rows back. When I run with the insert statement, a total of 9062 rows are inserted. What gives?
    <SQL>
    INSERT INTO mars_aes_data
    (rpt_id, shpdt, blno, stt, shpr_nad, branch_tableS, csgn_nad,
    csgnnm1, foreign_code, pnt_des, des, eccn_no, entity_no,
    odtc_cert_ind, dep_date, equipment_no, haz_flag, schd_no,
    schd_desc, rec_value, iso_ulti_dest, odtc_exempt, itn,
    liscence_no, liscence_flag, liscence_code, mblno, mot,
    cntry_load, pnt_load, origin_state, airline_prefix, qty1, qty2,
    ref_val, related, routed_flag, scac, odtc_indicator, seal_no,
    line_no, port_export, port_unlading, shipnum, shprnm1, veh_title,
    total_value, odtc_cat_code, unit1, unit2)
    SELECT 49, schemaP.tableS.shpdt, schemaP.tableS.blno,
    schemaP.tableS.stt, schemaP.tableS.shpr_nad,
    schemaP.tableM.branch_tableS, schemaP.tableS.csgn_nad,
    schemaP.tableS.csgnnm1, schemaP.tableD.foreign_code,
    schemaP.tableS.pnt_des, schemaP.tableS.des,
    schemaP.tableD.eccn_no, schemaP.tableN.entity_no,
    schemaP.tableD.odtc_cert_ind, schemaP.tableM.dep_date,
    schemaP.tableM.equipment_no, schemaP.tableM.haz_flag,
    schemaP.tableD.schd_no, schemaP.tableD.schd_desc,
    schemaP.tableD.rec_value,
    schemaP.tableM.iso_ulti_dest,
    schemaP.tableD.odtc_exempt, schemaP.tableM.itn,
    schemaP.tableD.liscence_no,
    schemaP.tableM.liscence_flag,
    schemaP.tableD.liscence_code, schemaP.tableS.mblno,
    schemaP.tableM.mot, schemaP.tableS.cntry_load,
    schemaP.tableS.pnt_load, schemaP.tableM.origin_state,
    schemaP.tableM.airline_prefix, schemaP.tableD.qty1,
    schemaP.tableD.qty2,
    schemaC.func_getRefs@link (schemaP.tableS.ptt, 'ZYX'),
    schemaP.tableM.related, schemaP.tableM.routed_flag,
    schemaP.tableM.scac, schemaP.tableD.odtc_indicator,
    schemaP.tableM.seal_no, schemaP.tableD.line_no,
    schemaP.tableM.port_export,
    schemaP.tableM.port_unlading, schemaP.tableS.shipnum,
    schemaP.tableS.shprnm1, schemaP.tableV.veh_title,
    schemaP.tableM.total_value,
    schemaP.tableD.odtc_cat_code, schemaP.tableD.unit1,
    schemaP.tableD.unit2
    FROM schemaP.tableD@link,
    schemaP.tableM@link,
    schemaP.tableN@link,
    schemaP.tableS@link,
    schemaP.tableV@link
    WHERE tableM.answer IN ('123', '456')
    AND SUBSTR (tableS.area, 1, 1) IN ('A', 'S')
    AND entity_no IN
    ('A',
    'B',
    'C',
    'D',
    'E',
    AND TO_DATE (SUBSTR (tableM.time_stamp, 1, 8), 'YYYYMMDD')
    BETWEEN '01-Mar-2009'
    AND '31-Mar-2009'
    AND tableN.shipment= tableD.shipment(+)
    AND tableN.shipment= tableS.shipnum
    AND tableN.shipment= tableM.shipment(+)
    AND tableN.shipment= tableV.shipment(+)
    <SQL>
    Edited by: user11263048 on Jun 12, 2009 7:23 AM
    Edited by: user11263048 on Jun 12, 2009 7:27 AM

    Can you change this:
    BETWEEN '01-Mar-2009'
    AND '31-Mar-2009'To this:
    BETWEEN TO_DATE('01-Mar-2009', 'DD-MON-YYYY')
    AND TO_DATE('31-Mar-2009','DD-MON-YYYY')That may make no difference but you should never rely on implicit conversions like that, they're always likely to cause you nasty surprises.
    If you're still getting the discrepancy, instead of and INSERT-SELECT, can you try a CREATE TABLE AS SELECT... just to see if you get the same result.

  • Jdbc sql insert to oracle DB.

    Dear All,
    I'm using the jdbc connector to insert data directly into an Oracle database table.  I've got the SQL insert command which XI has generated by using the logSQLStatement parameter and I've proved the statement is good by pasting it directly into Toad where it is executed perfectly.  However XI is throwing the following errors;-
    Unable to execute statement for table or stored procedure. 'SI_ORDER' (Structure 'STATEMENT') due to java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
    MP: exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'SI_ORDER' (structure 'STATEMENT'): java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
    Does anyone know what might be the problem or even where I should start to troubleshoot this?
    Any help is much appreciated.
    Pete.

    Your question is how to load data from a text file into arrays?
    Start with a
    StreamReader to read the file one line at a time.  Then break each line into individual values, and add each value to a
    List<T>.  Then call .ToArray() on each list to set the value of each array-bound parameter.
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Best solution for EXEC SQLu2026. INSERT? Time problem

    Hi:
    I have a problem with native sql in abap. I have next code and itu2019s working properly (see below) , but the problem occurs when abap internal table is too big, because exec sql u2026 endexec is executed one time for each internal table line, so it needs too much time.
    Do you know any solution? Is it possible to insert the internal table with only one exec sql?
    Thanku2019s in advance for your time.
        LOOP AT i_table.
          EXEC SQL.
            insert into oracle_table@db
            (value1,
             Value2
            values
            (:i_table-val1,
             :i_table-val2
          ENDEXEC.
        ENDLOOP.

    Definately this approach will take a lot of time.
    i would suggest that you create a table, fill that table with the internal table you are using for the insertion and use below mentioned code this will improve your processing time.
    Exec SQL.
    INSERT INTO
    EXEC SQL.
    insert into oracle_table@db
    (value1,
    Value2
    SELECT  COLUMN1, COLUMN2 FROM DUAL
    FROM ZTABLE
    ENDEXEC.

  • Insert single column

    Hi all.
    What is the sql statement for insert a single column to  the table?
    Let say i gt a student table and a admino column.
    Thank

    u can never insert a single column.
    atleast u should insert blanks to the other fields.
    inserting a row is possible , inserting single column will not be a normalised table.
    by the way u can update a single column.

  • Export as SQL INSERT generates dud SQL

    When I attempted to export data from a table as SQL INSERT statements it generated the statements with single quotes around the table name:
    SQL> Insert into 'JOHN_SMITH' values ('162142','89')
      2  /
    Insert into 'JOHN_SMITH' values ('162142','89')
    ERROR at line 1:
    ORA-00903: invalid table name
    SQL> Fortunately my text editor can do the necessary global replace :)
    SQL> Insert into "JOHN_SMITH" values ('162142','89')
      2  /
    1 row created.
    SQL> I am using Raptor #919
    Cheers, APC

    Wanted to clarify the table in insert - in the EA4 release, we will not wrap the table name in quotes at all, if you want to preserve multi-byte characters or mixed case table names, you need to wrap the table name in double quotes. We just removed the single quotes we had incorrectly put in. This makes it consistent with creating and modifying a table - i.e. you provide the quotes if you want them.
    -- Sharon

Maybe you are looking for