Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

LOOPing for personell_fluctuation


Hi,

I have the following challenge:

- In my personell_app, there is data on personell_fluctuation, which is defined as

     - the nr. of emps who left the company in a given month

     - relative to the nr. of emps the company had a month before

- For obvious reasons, this fluctuation is only reliable once a month is "complete" and done with (so today, for instance, I have two, for
   Jan and for Feb)

=> I have to create two LOOPs (as the operation I need to do involves a JOIN which doesn't work in just one)

=> Every LOOP should be executed (twice), once for Jan. and once for Feb. (I use a counter i which shall be < 3). I try doing a DO_LOOP (before, I had a FOR loop, but I want to make it dynamic)

=> For some reason, I cannot yet get that to work in the sense of producing a table with two records: I only get one, which means the
      2nd iteration of the LOOP overwrites the 1st.
  => How can I avoid this?

Thanks a lot!

Best regards,

DataNibbler

P.S.: I can tell that the LOOP as such is working:

- In the log, I can see two iterations

- The variable i has the value 3 after script_execution

=> The table should have two records (one per iteration), but that is not the case.

4 Replies
marcus_sommer

I suggest you creates a small example with dummy-data then without it's rather guessing.

- Marcus

datanibbler
Champion
Champion
Author

Hi Marcus,

now I have my loop, but for some reason I cannot see it fails every time - the log shows an "Invalid expression", but no details on the error.

Could it be - the help_text lets me assume sth. like that - that a LOAD statement inside a DO_LOOP must be written all in one line?

=> That is about the only possible reason I can think of: In the example, it is very simple and small and written in one line <=> I routinely write my LOAD_statement in several lines, every field in one line and every part of the WHERE_statement (and there are four parts to it here) in one line.

Could that be the reason the loop fails?

Thanks a lot!

Best regards,

DataNibbler

marcus_sommer

Hi DataNibbler,

one line relates only for control-statements and not for load-statements. I assume that really a invalid expression occurred perhaps caused through a variable with NULL. You could find it per "trace Variable;" or per using from script-debugger. If this not worked post your loop-script.

- Marcus

datanibbler
Champion
Champion
Author


Hi,

consider this solved.

I still have no idea exactly what happened, but basically, in one iteration of my LOOP there were no records that matched all of my WHERE criteria. So nothing was loaded.

I worked around that by implementing a "failsafe", a dummy record to be loaded when the actual LOAD fails.

=> Now I am looking at creating a join_field to join the two tables I get as a result from the two separate LOOPs.

Best regards,

DataNibbler