You are on page 1of 1

DynamicallyDetermineDB2LibraryinCognosFrameworkManager

ThisdocumentdescribesanapproachtodynamicallysettheschemapropertyforaCognosdatasourceinFrameworkManager.This isusefulwhenaschemaMUSTbesupplied(suchaswithDB2iSeries)andcanvarybetweenenvironments. Step1CreateDataSourceQuerySubject Createadatasourcequerysubjectthatqueriesthedatabaseandreturnsthenameofthedatabaseserver.Theexamplebelow illustratesaDB2query.ThequerywillonlyreturnonerowwithahardcodedvalueCURRENT_ENVIRONMENTandthenameofthe properlibrarytouse.Thecorrectlibrarytouseisbasedonthevalueofthedatabaseserverandacasestatementtoidentifythe schemanamethatgoeswitheach.


SELECT 'CURRENT_ENVIRONMENT' as CURRENT_ENVIRONMENT, case CURRENT SERVER when 'AS4DEV' then 'DEVSCHEMA' when 'AS4PROD' then 'PRODSCHEMA' else 'DEVSCHEMA' end as LIBRARY_NAME FROM SYSIBM.SYSDUMMY1

WhenthedatasourceconnectioninCognosConnectionisconfiguredfordevelopmentdata,asitwouldbeintheCognosDEV environment,thequerywillreturn: CURRENT_ENVIRONMENT DEVSCHEMA WhenthedatasourceconnectioninCognosConnectionisconfiguredforproductiondata,asitwouldbeintheCognosPROD environment,thequerywillreturn: CURRENT_ENVIRONMENT PRODSCHEMA Step2CreateParameterMap CreateaparametermapandselecttheoptionintheParameterMapWizardtobasethe parametermaponexistingqueryitems.SpecifythequerysubjectcreatedinStep1and specifythekeyastheCURRENT_ENVIRONMENTcolumnandsetthevalueasthe LIBRARY_NAMEcolumn. Step3DefineMacroforSchemaProperty ChangetheSchemapropertyforthedatasourceinCognosconnectiontoamacrothat referencestheparametermap.
#$[Dynamic Library]{'CURRENT_ENVIRONMENT'}#

Step4Test SettheconnectioninformationinCognosConnectiontoDEVenvironmentandtesttheconnectioninCognosConnectiontoensure itissetupproperly.Usequerystudioorreportstudiotoquerythedatabaseusinganobjectknowntohavedifferentcontentsfrom PROD.Verifytheaccuracyofthecontentandsavethereport.ChangetheconnectioninformationinCognosConnectiontopointto PROD.Rerunthesavedreportandthecontentshouldnowshowproductiondatavalues.

You might also like