COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Framework Manager => Topic started by: cognostechie on 07 Jul 2025 03:02:09 PM

Title: Macro to change Databases
Post by: cognostechie on 07 Jul 2025 03:02:09 PM
I swear I have done this before and it used to work but somehow in ver 11.2 it doesn't work.

I want to change the Database depending on which Database the user wants to connect to so I created two Data Sources in Cognos and reports are working from both. Now I created a Model Query subject with two columns.

1> DS_ID  - Value is '1'
2> DS_NAME - CASE
    WHEN #prompt('Type NewDB or LegacyDB','string')#  = 'LegacyDB' THEN 'LEGACYDB'
    ELSE 'NEWDB'
  END

LEGACY and NEWDB are the Data Sources in Cognos.

I created a Parameter Map with the name DS_NAME and pointed that to the Model Query Subject. DS_ID as the Key and DS_NAME as the Value.

In the Data Source , property - Content Manager Datasource - I am putting this #$[DS_NAME]{'DS_ID'}#

It gives an error 'QE-DEF-0286 Unable to find the connection #$[DS_NAME]{'DS_ID'}# in the Content Store'

What am I doing wrong?
Title: Re: Macro to change Databases
Post by: bus_pass_man on 08 Jul 2025 04:43:32 AM
I'm assuming that you consciously made the decision to not put the macro into the data source connection property and, instead, pursue this approach. Could you explain why that method was not suitable please. 
Title: Re: Macro to change Databases
Post by: cognostechie on 08 Jul 2025 07:29:10 PM
I don't exactly know what you mean by Data Source connection property. Are you referring to the connection of the Data Source in Cognos admin page or Data Source properties in FM? Both are different things. The Data Source object in FM is a local Data Source embedded inside the xml file which connects to the actual Data Source using the properties defined.

It is working now. The problem was the model was brand new so it was using DQM mode. It doesn't work in DQM models. When I made a CQM model, it worked. To double check it, I also converted the new DQM model to CQM and it worked! Seems like they disabled it for DQM models.
Title: Re: Macro to change Databases
Post by: bus_pass_man on 09 Jul 2025 05:21:13 AM
You can use macros.