Delete and creation of an element and data lost risk

Post Reply
simontanguay
Posts: 6
Joined: Thu Jan 22, 2015 3:25 pm
OLAP Product: none
Version: 10.1.1
Excel Version: 2010

Delete and creation of an element and data lost risk

Post by simontanguay »

I have to run an old process to update an dimension. This process is run once a year to add new months to a dimension.

The way the programmer implemented it, all the elements are deleted in the 'Prolog' section and then created them again in the "Metadata" section (based on a csv file that include the old and new months to be created). The attributes are set in the 'Data' section.

Simplification of the code:

Prolog:

Code: Select all

 DimensionDeleteAllElements(vDimName);
AttrDelete(vDimName, 'desc');
AttrInsert(vDimName, '', 'desc', 'A');
Metadata:

Code: Select all

DimensionElementInsert(vDimName,'',Periode,'N');
Data:

Code: Select all

AttrPutS(Periode, vDimName, Periode, 'Desc');

There are no good reason to delete the existing elements so I consider rewriting the code to only add the new elements.

Still, I'm curious to know why the existing process work at all. I ran the code in a test environment and there is no data lost. Assuming that the process doesn't crash, is it actually safe? Are the dimension maintained until the end of the process even if in theory they have been deleted, and since they are created again, there is no real risk (beside a crash of the process)?
User avatar
Steve Rowe
Site Admin
Posts: 2464
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Delete and creation of an element and data lost risk

Post by Steve Rowe »

Hi,
(I moved this to the right forum)
In general I would never put a DimensionDeleteAllElements in any TI in any system that I am responsible for.
The risk of data loss can never be totally removed. For example, are there any error checks for the presence of the csv before the delete? How can you be 100% sure that the csv is correct without running the TI (you can't).
In addition it tends to break subsets that point to alias
The code works because the TI is working on copy of the dimension which it saves back over the original when it is complete, so as long as all the elements are back in the same place at the end of job all should be OK.

Cheers,
Technical Director
www.infocat.co.uk
simontanguay
Posts: 6
Joined: Thu Jan 22, 2015 3:25 pm
OLAP Product: none
Version: 10.1.1
Excel Version: 2010

Re: Delete and creation of an element and data lost risk

Post by simontanguay »

Thanks. I effectively just ran the old process by mistake and my heartbeat stopped for a second... hopefully it was on the test environment. Yes, better not have any delete at all...
Post Reply