Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Specifying Table Name Dynamically in Insert Statement....  RSS feed

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i specify table name dynamically in insert statement ? as follows...

 
Scott Selikoff
author
Bartender
Posts: 4085
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, why wouldn't you be able to? For the most part, JDBC does not validate or even understand the SQL you send to the database server other than its just a SQL String.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36875
481
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jigar,
Yes, you can build a Statement's SQL through String concatenation.

Note that you cannot write "insert into table ? ..." in a PreparedStatement though.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scott Selikoff:
JDBC does not validate or even understand the SQL you send to the database server other than its just a SQL String.


Nice clarification Scott,
I really appreciated your knowledge..
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!