Using Query Macros

A macro is a fragment of code that you can insert in the Select statement of a query or in an expression. For example, add a macro to insert a new data item containing the user's name.

You can include references to session parameters, parameter maps, and parameter map entries in macros. Parameter values are set when you run the query. For example, you can use the language session parameter to show only the data that matches the language setting for the current user.

Macros can be used in these different ways:

You can also add query macros to the IBM® Cognos® Framework Manager model. For more information, see the Framework Manager User Guide.

Support for query macros in IBM Cognos Report Studio includes the same capabilities as macros used in Framework Manager. However, Report Studio query macros do not extend to the layout. Therefore, when making changes to the query using macros, you must bear in mind the side-effects on the layout. For example, if a macro removes a column from the query that the layout refers to, a run-time error will occur.