Hello,
I have a situation where a single value in TM1 could possibly relate to 2 different values back in the relational database where I need to get the data in a drill through.
For example:
Market is set to UNAL in TM1.
In the Prolog, I was thinking of adding the following if-then-else statement:
IF (Market @= 'UNAL');
MarketSQL = "AND BUF.BU_CODE_MKT in (' ', 'UNAL')";
ELSE;
MarketSQL = "AND BUF.BU_CODE_MKT = '?Market?'";
ENDIF;
I am getting the following error:
Syntax error on or before:
"AND BUF.BU_CODE_MK
invalid expression
Once I get the MarketSQL set, I will add it to the query for the drill through with ?MarketSQL?
Thoughts??
Thank you!
SQL Statement Creation Question for Drill Through
-
- MVP
- Posts: 2836
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: SQL Statement Creation Question for Drill Through
Look at the code where you are assigning a string value to the variable Market_SQL. Strings have to be encapsulated inside an apostrophe ('), not a quotation mark ("), in TM1. You'll also have to play around with your string building to get the syntax correct to get the apostrophe into the SQL string as well. This will be a good exercise for you to learn how to build strings in a TI process.
-
- Posts: 19
- Joined: Fri Jan 13, 2012 4:31 pm
- OLAP Product: TM1
- Version: 9.1 Release 3
- Excel Version: Excel 2007
Re: SQL Statement Creation Question for Drill Through
I was hopeful that I could use double quotes and realized quickly that I needed to use single quotes.
I was able to create the SQL that I needed by using | & char(39):
IF (Market @= 'UNAL');
MarketSQL = 'AND BUF.BU_CODE_MKT in (' | char(39) | ' ' | char(39) | ', ' | char(39) | '?Market?' | char(39) | ')';
ELSE;
MarketSQL = 'AND BUF.BU_CODE_MKT = ' | char(39) | '?Market?' | char(39);
ENDIF;
I was able to send MarketSQL out with ASCIIOUTPUT and it helped me debug what I was doing. I was able to create the proper lines.
I was able to create the SQL that I needed by using | & char(39):
IF (Market @= 'UNAL');
MarketSQL = 'AND BUF.BU_CODE_MKT in (' | char(39) | ' ' | char(39) | ', ' | char(39) | '?Market?' | char(39) | ')';
ELSE;
MarketSQL = 'AND BUF.BU_CODE_MKT = ' | char(39) | '?Market?' | char(39);
ENDIF;
I was able to send MarketSQL out with ASCIIOUTPUT and it helped me debug what I was doing. I was able to create the proper lines.