mardi 30 janvier 2018

IF statement not retuning all values. Is there a limit to IF variables?

I have a nightly report that Sums up the values of our GL codes per company division from a Stored Procedure. The divisions are broken up into IP, RE and ALL. The IP and RE totals are correct but the value that returns for the ALL group seems be be getting cut off before all of the GL codes are totaled. There are 32 GL codes in the ALL group. For example IP returns $543299, RE returns $1066129 and the ALL group returns $1526900. The ALL total should be $1609428. I'm able to identify the exact number that is missing and if I remove all of the GL codes and put in just the ones that are not added to the ALL total, it will return the correct value but not when I add it to the full statement.

Below is how I have the statement written. My only idea is that it is getting cut off before all of them get processed. I'm not getting any errors when executing the statement.

If (@DIVISION = 'IP')
            Set @GLCODE = ('1.10.000.4200,2.10.000.4200,1.10.000.4210,2.10.000.4210,1.10.000.4220,2.10.000.4220,1.10.000.4301,1.10.000.4302,2.10.000.4302,1.10.000.4310,2.10.000.4310')
        Else If (@DIVISION = 'RE')
            Set @GLCODE = ('1.20.000.4100,2.20.000.4100,3.20.000.4100,1.20.000.4120,2.20.000.4120,3.20.000.4120,1.20.000.4302,2.20.000.4302,3.20.000.4302,1.20.000.4310,2.20.000.4310,3.00.000.4310,1.30.000.4304,2.30.000.4304,1.30.000.4350,2.30.000.4350,1.30.000.4351,2.30.000.4351,1.30.000.4352,2.30.000.4352,1.30.000.4353')
        Else If (@DIVISION = 'ALL')
            Set @GLCODE = ('1.10.000.4200,1.10.000.4210,1.10.000.4220,1.10.000.4301,1.10.000.4302,1.10.000.4310,1.20.000.4100,1.20.000.4120,1.20.000.4302,1.20.000.4310,1.30.000.4304,1.30.000.4350,1.30.000.4351,1.30.000.4352,1.30.000.4353,2.10.000.4200,2.10.000.4210,2.10.000.4220,2.10.000.4302,2.10.000.4310,2.20.000.4100,2.20.000.4120,2.20.000.4302,2.20.000.4310,2.30.000.4304,2.30.000.4350,2.30.000.4351,2.30.000.4352,3.00.000.4310,3.20.000.4100,3.20.000.4120,3.20.000.4302')
        Else
            Set @GLCODE = ('00.00.000.0000')

Aucun commentaire:

Enregistrer un commentaire