How to iterate over odbc input columns?
Posted: Tue Nov 16, 2021 9:08 am
As I want to fill a cube with as less code as possible, I was considering looping over the sql server input. In my example a value gets written, if several conditions are met. This works fine, unless I want to put it all in a loop. I may use a flat dimension to represent the input variables, but this works only in the CellPutN statement. I also want to check the if conditions for every input column. How do I achieve this? I could simply write a statement representing every input column. Where I put the question marks, there would be the input variable name and a loop wouldn't be necessary. But This would mean some hundreds of lines of code. Any suggestions?
Code: Select all
# define loop input, where "DIM_flat_iter" represents a dimension containing the relevant input variables as dimension elements
sCube = 'xyCube';
sDIM = 'DIM_flat_iter';
DimCount = DIMSIZ('sDIM');
i = 0;
# start iteration
WHILE ( i < DimCount);
i = i + 1;
elemDIM = DIMNM(sDIM, i );
varDIM = ?? ; # ----> how do I capture this, as string values from a dimension cannot represent input variables, I guess
if (Q_Code @<>' ');
if (varDIM @= 'X');
if (QAB @= 'X');
CellPutN(1, sCube, 'QAB', elemDIM, Q_Code, 'Marker');
endif;
endif;
endif;
END;