You can translate the question and the replies:

Table name at the runtime

Hi We have requirement to dynamically query a table , whose name is stored in another table.. E.g. View 1 has - Table,Date View01012022, 01/01/2022 View02012022,02/01/2022 View03012022,03/01/2022 First query View1 to get Table name .e.g View01012022 and then query View01012022 to get actual data. Kindly suggest
23-06-2022 08:19:32 -0400

1 Answer

Hello, To get information about a view whose name is in another table, I would create a view with a parameter for the name and create a join view with two views that contains the same name by doing the following steps: 1. Prepare the view that has the names of tables 2. Create a jdbc datasource pointed at the VDP you're running on 3. Create base view from query with a parameter by selecting the ‘Create from query’ option. Enter the view name and then SQL query with an interpolation variable on the dialog like an example below: `Select * from @tablename` 4. Create a Join view between the two views in a select statement on the parameter equaling the column in the other view that contains the target table name. For example: `SELECT <select fields> From view_1 AS a JOIN view_2 as b on a."TABLENAME" =` I would keep in mind that all of the tables that I queried must have the same schema. The document [Creating Base Views from SQL Queries]( describes how to create base views SQL query that have interpolation variables. I would use this document as a useful reference. Hope this helps!
Denodo Team
28-06-2022 12:57:21 -0400
You must sign in to add an answer. If you do not have an account, you can register here