Page 1 of 1
Prevent error on duplicate alias names - TI Process
Posted: Sun Apr 17, 2011 11:29 pm
by BigG
Hi, I have a employee list with emp number as the element name and two aliases, one emp number and name (which is always unique) and another just name (which does have duplicates). I have tried to recognise during attribute (alias) updates the duplicate 'names', but my IF statement below only works if I run the process once, If I was to reload the process will then all employee names are now not unique because they are in an element alias, therefore a concatenate occurs to make it unique...
Anyone have any further ideas?
Code: Select all
If( DIMIX('Employee',vEmployee_Name )>0);
ATTRPUTS(vEmployee_Name|' - '|vEmployee_No,'Employee',vEmployee_No,'Description');
else;
ATTRPUTS(vEmployee_Name,'Employee',vEmployee_No,'Description');
Endif;
Re: Prevent error on duplicate alias names - TI Process
Posted: Sun Apr 17, 2011 11:51 pm
by Alan Kirk
BigG wrote:Hi, I have a employee list with emp number as the element name and two aliases, one emp number and name (which is always unique) and another just name (which does have duplicates). I have tried to recognise during attribute (alias) updates the duplicate 'names', but my IF statement below only works if I run the process once, If I was to reload the process will then all employee names are now not unique because they are in an element alias, therefore a concatenate occurs to make it unique...
Anyone have any further ideas?
Code: Select all
If( DIMIX('Employee',vEmployee_Name )>0);
ATTRPUTS(vEmployee_Name|' - '|vEmployee_No,'Employee',vEmployee_No,'Description');
else;
ATTRPUTS(vEmployee_Name,'Employee',vEmployee_No,'Description');
Endif;
I'm assuming that the names can change, since women who get married still sometimes change their name and the like. (If that wasn't the case you could just do the DimIx on the number + name alias and ignore anyone who showed up.)
However since we do have that complication, one way is as follows:
(a) Use the DimIX to get the index before you hit the If block, and store it in a variable.
(b) If that's >0, then use DimensionElementPrincipalName to get the employee number that the row relates to, and store that in a variable too. This will get you the employee number of the element which already has that employee name. (Otherwise set that variable to an empty string.)
(c) The If block test then becomes IF the DimIX value = 0 then write it to description (since it doesn't exist yet), ELSE IF DimIX > 0 & the element's principal name @<> the vEmployee_No (meaning that it's a different employee), then write the expression that you currently have under the If.
Re: Prevent error on duplicate alias names - TI Process
Posted: Mon Apr 18, 2011 12:28 am
by BigG
fantastic
adding
Code: Select all
DimensionElementPrincipalName('Employee',vEmployee_Name ) @<> vEmployee_No
to the IF argument is the result I wanted.
Code: Select all
If(DIMIX('Employee',vEmployee_Name)>0 & DimensionElementPrincipalName('Employee',vEmployee_Name ) @<> vEmployee_No);
ATTRPUTS(vEmployee_Name|' - '|vEmployee_No,'Employee',vEmployee_No,'Description');
else;
ATTRPUTS(vEmployee_Name,'Employee',vEmployee_No,'Description');
Endif;
thanks Alan, you are a champion
Re: Prevent error on duplicate alias names - TI Process
Posted: Mon Apr 18, 2011 11:09 pm
by ExApplix
In the TI Process if we use RECREATE instead of using UPDATE then I think we will not have to worry about this situation.
Is there any harm in using the recreate option?
Re: Prevent error on duplicate alias names - TI Process
Posted: Mon Apr 18, 2011 11:20 pm
by Alan Kirk
ExApplix wrote:In the TI Process if we use RECREATE instead of using UPDATE then I think we will not have to worry about this situation.
Is there any harm in using the recreate option?
Two pieces.
The first is that you're relying on the accursed code wizard via the Map tab. If you want to unshackle yourself, you need to learn to do your own coding and consign anything that is thrust between the Generated Statements lines to the toxic waste centre of history. The code that's generated by the Map tab is fiddly to produce, and highly inflexible.
Second, look at what the code generates. It includes the DimensionDeleteAllElements command in the Prolog. While that statement is a necessary inclusion in the TI language, IMHO it's just too radically dangerous to use outside of a test or development environment. It essentially destroys your dimension and rebuilds it from the ground up. As long as nothing goes wrong, you won't lose any data.
But if, say, your data source is corrupted and not all of the N level elements have been added back in before the process ends, then "tears before tea time" will be an understatement.