CREATE ACTION Statement

Analysis Services Programming

Analysis Services Programming

CREATE ACTION Statement

This statement allows the user to create action definitions that can be associated with a member and executed when that member is referenced.

BNF

ALTER CUBE <cube name>
    CREATE ACTION <action name> <action body>

CREATE ACTION <cube name>.<action name> <action body>

<action body> ::=
FOR <target object>
AS '<MDX expression>'
[, TYPE = '<action type>']
[, INVOCATION = '<action invocation>']
[, APPLICATION = '<app name>']
[, DESCRIPTION = '<action description>']
[, CAPTION = '<MDX expression>']

<target object>:: CUBE
|    <dimension name> [MEMBERS]
|    <level_name> [MEMBERS]
|    CELLS
|    SET

<action type>:: URL | HTML | STATEMENT |
    DATASET | ROWSET | COMMANDLINE | PROPRIETARY

<action invocation>:: INTERACTIVE | ON_OPEN | BATCH

ALTER CUBE <cube name>
    DROP ACTION <action name>

DROP ACTION <cube name>.<action name>

Remarks

The following table describes the different types of actions available in Microsoft® SQL Server™ 2000 Analysis Services.

Action type Description
URL The returned action string is a URL that should be launched using an Internet browser.
HTML The returned action string is an HTML script. The string should be saved to a file and the file should be rendered using an Internet browser. In this case, a whole script may be executed as part of the generated HTML.
STATEMENT The returned action string is a statement that needs to be executed by setting the ICommand::SetText method of a command object to the string and calling the ICommand::Execute method. If the command does not succeed, an error is returned.
DATASET The returned action string is a Multidimensional Expressions (MDX) statement that needs to be executed by setting the ICommand::SetText method of a command object to the string and calling the ICommand::Execute method. The requested interface ID (IID) should be IDataset. The command succeeds if a data set has been created. The client application should allow the user to browse the returned data set.
ROWSET Similar to DATASET, but instead of requesting an IID of IDataset, the client application should ask for an IID of IRowset. The command succeeds if a rowset has been created. The client application should allow the user to browse the returned rowset.
COMMANDLINE The client application should execute the action string. The string is a command line.
PROPRIETARY A client application should not display nor execute the action unless it has a custom, nongeneric knowledge of the specific action. Proprietary actions are not returned to the client application unless the client application explicitly asks for these by setting the appropriate restriction on the APPLICATION_NAME.

It is possible for client applications to create and run actions that are unsafe; it is also possible for client applications to use unsafe functions. To avoid these situations, use the UDF Safety Options property. For more information, see UDF Safety Options Property.

Scope

Each action is defined for a specific cube and has a unique name in that cube. An action can have one of the following scopes:

Cube scope

For actions independent on specific dimensions, members, or cells, for example: "Launch terminal emulation for AS/400 production system".

Dimension scope

The action applies to a specific dimension. Those actions are not dependent on specific selection of levels or members.

Level scope

The action applies to a specific dimension level. Those actions are not dependent on specific selection of a member in that dimension.

Member scope

The action applies to specific level members.

Cell scope

The action applies to specific cells only.

Set scope

The action applies to a set only. The name ActionParameterSet is reserved for use by the application inside the expression of the action.

Examples
A. Creating an Action

The following example creates an action that enables the client application to open a Web page with Active Server Pages (ASP) script. This script displays the details of a customer, given the customer ID number.

CREATE ACTION [Sales Cube].[Show Customer Details] 
FOR [Customer] MEMBERS As 
'iif(Customers.CurrentMember.Properties("Existing Customer") = "True",
"http://MyServer/CustomerDetails.ASP?CustID=" + Customers.CurrentMember.ID,'')
TYPE = URL
APPLICATION = 'IE'
DESCRIPTION = 'Launch the customer details page for this specific customer''

See Also

Actions