This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

whts wrong in this statement?  RSS feed

 
Keshini Weerasuriya
Greenhorn
Posts: 24
  • 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: 1084
Java Oracle Spring
  • 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
    • 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
    • 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: 1084
    Java Oracle Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    put the complete method

    Shailesh
     
    Keshini Weerasuriya
    Greenhorn
    Posts: 24
    • 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
    • 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
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Martin.. That worked.. :-)
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!