Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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...

 
author
Bartender
Posts: 4093
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.
 
author & internet detective
Marshal
Posts: 37714
579
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.
 
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..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!