Utility: CLEAR_CUBE

By: Mark Thompson
February 12, 2007
Related Topics:

I’ve written a utility called Clear_Cube which clears all data from all measures in a cube.

 

Syntax is: call clear_cube(‘cubename’)

Example: call clear_cube(‘MY_DATA’)

 

 


"Program: Clear_Cube
"Purpose: Clear all contents from a cube
"Author:  Mark Thompson - Vlamis Software Solutions
"Date:    February, 2007

arg _cubearg  text

vrb _cube     text
vrb _cubevar  text
vrb _argcnt   int

_cubearg = upcase(_cubearg)
_cubevar = joinchars(_cubearg '_PRT_TOPVAR')
_cube = joinchars(_cubearg '.CUBE')

"Make sure cube exists
if not isvalue(all_cubes,_cube)
then do
  show joinchars(_cube ' is not a value of ALL_CUBES')
  return
doend

limit all_cubes to _cube
limit all_measures to cube_measures
limit all_measures keep measure_catalog(measure_prop 'MEASTYPE') eq 'BASE'

if exists(_cubevar)
then do
  show joinchars(tod ' begin clearing all data from compressed cube ' _CUBE)
  show joinchars(tod ' clearing data from ' _cubevar)
  &joinchars('clear all from ' _cubevar)
  show joinchars(tod ' ended clearing all data from compressed cube ' _CUBE)
doend
else do
  show joinchars(tod ' begin clearing all data from non-compressed cube ' _CUBE)
  for all_measures
  do
    _cubevar = joinchars(changechars(extchars(all_measures 1 numchars(all_measures)-8),'.','_') '_STORED')
    if exists(_cubevar)
    then do
      show joinchars(tod ' clearing data from ' _cubevar)
      &joinchars('clear all from ' _cubevar)
    doend
    else show joinchars(tod ' ' _cubevar ' does not exist')
  doend
  show joinchars(tod ' ended clearing all data from non-compressed cube ' _CUBE)

doend

 

LinkedIn
Twitter
Facebook
Reddit

Related Posts:

Let’s discuss your options

Contact us to discuss next steps.