File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is this SQL Stament correct ???

 
vikas de
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String table="tableName";
String tableValue="12";
int result=stmt.executeUpdate(Insert into '"+table+"' values('"+tableValue+"')");
is this statement correct !!!???

[This message has been edited by vikas de (edited March 30, 2001).]
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be almost correct if your table only has a single column of a text type. You should remove the quotes from the table name, first, though. As with "select" statements, it's almost always better to specify the column names:
int result = stmt.executeUpdate("insert into " + table + " (colname) values('" + tableValue + "')" );
If your column has a numeric type, you should not put quotes on the value either:
int result = stmt.executeUpdate("insert into " + table + " (colname) values(" + tableValue + ")" );

 
vikas de
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a lot...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic