Dynamic SQL Table Names in Turbo Integrator

Post Reply
ExApplix
Posts: 103
Joined: Mon Sep 21, 2009 7:09 pm
OLAP Product: Cognos Tm1
Version: 10.2.2
Excel Version: 2016

Dynamic SQL Table Names in Turbo Integrator

Post 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.
User avatar
rkaif
Community Contributor
Posts: 328
Joined: Fri Sep 05, 2008 6:58 pm
OLAP Product: IBM Cognos TM1
Version: 9.1 or later
Excel Version: 2003 or later

Re: Dynamic SQL Table Names in Turbo Integrator

Post 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?'
Cheers!
Rizwan Kaif
jstrygner
MVP
Posts: 195
Joined: Wed Jul 22, 2009 10:35 pm
OLAP Product: TM1
Version: 9.5.2 FP3
Excel Version: 2010

Re: Dynamic SQL Table Names in Turbo Integrator

Post 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
Post Reply