COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: pooja on 10 May 2010 11:59:34 AM

Title: making prompt optional
Post by: pooja on 10 May 2010 11:59:34 AM
how can we make prompt "Optional", if prompt is coming from direct SQL)

ex- (#promptmany('USER_NAME' , 'CHAR')# )

we tried on properties...but we found only REQUIRED = YES/NO, but not "Optional"

please share any thoughts

thank you in advance


Title: Re: making prompt optional
Post by: pooja on 11 May 2010 06:52:22 AM
 ???
Title: Re: making prompt optional
Post by: CognosPaul on 11 May 2010 08:54:27 AM
Adding a default value to the prompt macro will make it optional.

You could, for instance, make your filter something like this:

#prompt('Country'
,'string'
,' '
,'table.country = ')#

This will return a space (' ') if nothing is entered, or will return table.country = 'testValue'
Title: Re: making prompt optional
Post by: pooja on 11 May 2010 09:04:02 AM
@Paul, thank you

what is this table.country ..??
Title: Re: making prompt optional
Post by: CognosPaul on 12 May 2010 02:37:57 AM
The table.country was an example.

If you're using direct SQL instead of going through framework you just need to place the prompt macro into the SQL box.

As an example your direct SQL might be like this:

select * from SalesByCountriesView

If you want the user to be able to filter a specific view you could change the SQL to:

select * from SalesByCountriesView where #prompt('Country','string','1=1','SalesByCountriesView.country=')#

On run time Cognos will give the user an optional textbox prompt. Should the user not select anything the following SQL will be run: select * from SalesByCountriesView where 1=1 Nothing will be filtered as 1 always equals 1. If the user does enter a country, Borogravia for example, the SQL will look like:select * from SalesByCountriesView where SalesByCountriesView.country='Borogravia'

Title: Re: making prompt optional
Post by: pooja on 12 May 2010 08:16:01 AM
thank you So much