Overview | Reference | Examples

The first few examples are for Visual Basic and are designed to show the ways in which the component can be used. All examples are based on a local server with the Foodmart sample OLAP database. To use VBScript instead, substitue Dim objDSOCtrl As New DSOCtrl.OLAPProc for Set objDSOCtrl = CreateObject("DSOCtrl.OLAPProc"). Remember to declare objDSOCtrl, and change the process type to a numeric, as the constants will be unavailable.


VB 1:
Perform a default cube process, as no ProcessType is specified, and return the time taken.

Dim objDSOCtrl As New DSOCtrl.OLAPProc
objDSOCtrl.ProcessCube ".", "FoodMart", "Sales"
MsgBox objDSOCtrl.ProcessDuration


VB 2:
Assign properties individually and perform a default cube process.

Dim objDSOCtrl As New DSOCtrl.OLAPProc
objDSOCtrl.Server = "."
objDSOCtrl.Database = "FoodMart"
objDSOCtrl.Cube = "Sales"
objDSOCtrl.ProcessType = processDefault
objDSOCtrl.ProcessCube


VB 3:
Use the ConnectCube method and return the last processed. Then process the cube and return the date again, and the time taken.

Dim objDSOCtrl As New DSOCtrl.OLAPProc
objDSOCtrl.ConnectCube ".", "FoodMart", "Sales"
MsgBox objDSOCtrl.LastProcessed
objDSOCtrl.ProcessCube , , , processFull
MsgBox objDSOCtrl.LastProcessed
MsgBox objDSOCtrl.ProcessDuration


T-SQL:

I have created a two stored procedure samples as wrappers around the sp_OAxxxx code required to utilise DSOCtrl. Both require the two OLE Automation Return Codes and Error Information stored procedures detailed in SQL Server Books Online (msoleerror.sql)

sp_DSOCtrl_ProcessCube (spDSOCtrlProcessCube.sql)
This example will process the cube Sales in the FoodMart DB on the local server.

EXEC master.dbo.sp_DSOCtrl_ProcessCube ".", "FoodMart", "Sales"

sp_DSOCtrl_ProcessAllDimensions (spDSOCtrlProcessAllDimensions.sql)
This example will process all dimensions in the FoodMart DB on the local server. The process duration is returned as an output parameter and printed.

DECLARE @ProcessDuration datetime
 EXEC master.dbo.sp_DSOCtrl_ProcessAllDimensions ".", "FoodMart",
   @ProcessDuration OUTPUT
 PRINT CONVERT(char(8), @ProcessDuration, 108)