This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

whts wrong in this statement?

 
Keshini Weerasuriya
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.. I'm trying to save changes and update the record. But this doesn't seem to work. Can anyone help?

st.executeUpdate("UPDATE Client " +
"SET (CliId = '"+id+"', Surname = '"+surname+"', FirstName = '"+firstname+"', Title = '"+Gen+"',NICNo = '"+NIC+"' , Image = '"+image+"',Address = '"+Address+"', TelNo = '"+no+"',Email = '"+mail+"')");
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Is there any exception ?
  • Are you issuing a commit, after your update operation.
  • Just a suggestion, use PreparedStatement.



  • Shailesh
     
    Martin Simons
    Ranch Hand
    Posts: 196
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well, for one, you don't need parens around the set fields, also a couple
    of your field names have "No" in the name, which I assume means number.
    You are adding these fields as if they are strings, so check that those
    fields are actually character and not number types in the database, and
    last, but definately not least, there is no where clause in this update
    statement. Do you really wish to update every row in the table with this
    information or did you want to only update a specific row?
     
    Keshini Weerasuriya
    Greenhorn
    Posts: 24
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    No exceptions.. But the new data doesn't get updated
     
    Shailesh Chandra
    Ranch Hand
    Posts: 1082
    Java Oracle Spring
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    put the complete method

    Shailesh
     
    Keshini Weerasuriya
    Greenhorn
    Posts: 24
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I changed the statement to

    String query = "UPDATE Client SET (CliId = '"+id+"', Surname = '"+surname+"', FirstName = '"+firstname+"', Title = '"+Gen+"',NICNo = '"+NIC+"' , Image = '"+image+"',Address = '"+Address+"', TelNo = '"+no+"',Email = '"+mail+"') WHERE CliId = '" +id+ "'";

    st.executeUpdate(query);

    Now it says
    java.sql.SQLException: ORA-00907: missing right parenthesis
     
    Martin Simons
    Ranch Hand
    Posts: 196
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I would say remove the parens around the set fields.
     
    Keshini Weerasuriya
    Greenhorn
    Posts: 24
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Martin.. That worked.. :-)
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic