Page 1 of 1

Dynamic SQL Table Names in Turbo Integrator

Posted: Wed May 19, 2010 8:10 pm
by ExApplix
I know that we can use Parameters within the WHERE clause of SQL statements in the TI like

Code: Select all

SELECT * 
FROMTableName
WHERE ColumnName='?myPrarmeter?'
But I want to change the Table Name 'dynamically' in the FROM clause so that the Table Name is based on whatever is the value in the Parameter. The Table Names in the backend database (Oracle in my case) changes from year to year e.g. TableName08, TableName09, TableName10 etc.

I tried the following, but it doesnt work

Code: Select all

SELECT * 
FROM'?myTableName?'
WHERE ColumnName='?myPrarmeter?'
Any help would highly be appreciated.

Re: Dynamic SQL Table Names in Turbo Integrator

Posted: Wed May 19, 2010 10:49 pm
by rkaif
Do not use the quotes for the Table name. You have to slightly change your code to:

Code: Select all

SELECT *
FROM ?myTableName?
WHERE ColumnName='?myPrarmeter?'

Re: Dynamic SQL Table Names in Turbo Integrator

Posted: Wed May 26, 2010 1:12 pm
by jstrygner
I don't know, if you are aware of a TI function you can use in Prolog tab to determine the whole query:

DatasourceQuery
This TurboIntegrator local variable sets the query string to use with the data source.
Syntax
DatasourceQuery='Query';

This way you can differ not only the table name, but the whole query (once it can be pure SELECT without WHERE section, once it can use some GROUP BY, HAVING and other stuff), you just should make sure your column names after calling such a select should remain the same (you can use AS for each column), so TI has the same variables.

HTH