Syntax of a dimension query

This is the syntax of a dimension query:

OLAPElementList list = on <connection> select <spec> from <dimension>

The arguments of the syntax have these definitions:

  • <connection> is an existing instance of OLAPConnection,
  • <dimension> is a name of dimension, either a string literal or string variable,
  • <spec> is a specifier of elements to select. It is always one of these keywords:
    • all – to select all elements
    • parents – to select only parent elements
    • leaves – to select only child elements

Example of a dimension query which selects all elements from a dimension specified by the dimeName variable


     OLAPConnection connection = OLAPCreateNamedConnection("");

	string errorMessage = "";
	int errorCode = 0;

	string sDimension = "Product";
	string nameAttribute = "NAME";

	try
	{
		OLAPElementList list = on connection select all from sDimension;
		foreach (OLAPElement e in list)
		{
			WriteLine("\t" + ToString(e));
		}
	}
	catch (errorMessage, errorCode)
	{
		WriteLine("Exception: " + errorMessage);
	}

	OLAPDisconnect(connection);

The DimensionQuery statement throws an exception in these cases:

  • The specified dimension does not exist.
  • The specified hierarchy does not exist.
  • The specified attribute for sorting or ordering does not exist.
  • The connection to OLAP is not valid.
  • An error occurs while communicating with OLAP.