• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic sql - table name, column name unknown

 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way I can execute an insert like
insert into table_name(filed1, field2 ...)
values (vf1, vf2 ..)
Here everthing is variable. L like to pass table names, column names along with values to be inserted at runtime. I am writing a SQL that fits all table designs with primitive datatypes.

Any idea how to do it in JDBC?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj,
You need to build the [SQL] string in your java code.

If I understand your question correctly, you need to do something like the following:
[NOTE: Uncompiled and untested.]

Hope this helps clarify things for you.

Good Luck,
Avi.
 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I intend to use JSTL - c:query tag etc. Does that support this kind of dynamic sql, wher tablenames, colnames are unknown?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raj,
You asked:

Does [JSTL] support this kind of dynamic sql

I don't know. I don't use JSTL. Try the JSP forum.

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic