Fork me on GitHub
#sql
<
2019-08-11
>
dcj19:08:19

This is probably an extremely basic ("dumb") question: I am trying to obtain the table names from several databases in a MSFT SQL Server, via the jtds driver. The hardcoded query works fine. I can't figure out how to parameterize the FROM part of the query, this is what I tried and it did not work:

(jdbc/execute! c ["select table_name from ? where TABLE_TYPE = 'BASE TABLE'" "AIRPORT.INFORMATION_SCHEMA.TABLES"])
Is this possible, if so, what I am doing incorrectly?

seancorfield19:08:37

I don't believe JDBC allows parameterization of the from clause.

dcj19:08:33

OK, thx. For this simple case, I can just create the entire string myself, and hand it to execute!.

seancorfield20:08:03

@dcj Take a look at HoneySQL for a nice way to programmatically build queries. You'd be able to do that query with the from as a parameter.

dcj20:08:36

Cool, will do!