Subject Calling procedure from select
Author Michael Vilhelmsen
Hi

I have made a procedure that has 3 Input Parameter and 1 output
parameter. The procedure is called BeregnDG

I then have a select statement like this


Select
Navn,
SalgSalgspris,
SalgMoms,
SalgKostpris,
SalgDb,
SalgDg,
(Select DB from BeregnDG
(LeverKobSalgLager.SalgSalgspris,LeverKobSalgLager.SalgKostpris,LeverK
obSalgLager.SalgMOms))
from LeverKobSalgLager
Where
Navn = 'Adidas Danmark A/S' and
afdeling_ID = '001' and
(aar*100)+mdr < 200204

This works fine


But if I wan't to have a SUM of some records I try to do this:

Select
Navn,
SUM(SalgSalgspris),
SUM(SalgMoms),
SUM(SalgKostpris),
SUM(SalgDb),
SUM(SalgDg),
((Select DB from BeregnDG(SUM(LeverKobSalgLager.SalgSalgspris),SUM
(LeverKobSalgLager.SalgKostpris),SUM(LeverKobSalgLager.SalgMOms))))
from LeverKobSalgLager
Where
Navn = 'Adidas Danmark A/S' and
afdeling_ID = '001' and
(aar*100)+mdr < 200204
group by navn

If I do this, I get an error saying INVALID COLUMN REFERENCE


Then I added MAX before my "select DB from...."
Select
Navn,
SUM(SalgSalgspris),
SUM(SalgMoms),
SUM(SalgKostpris),
SUM(SalgDb),
SUM(SalgDg),
MAX((Select DB from BeregnDG(SUM
(LeverKobSalgLager.SalgSalgspris),SUM
(LeverKobSalgLager.SalgKostpris),SUM(LeverKobSalgLager.SalgMOms))))
from LeverKobSalgLager
Where
Navn = 'Adidas Danmark A/S' and
afdeling_ID = '001' and
(aar*100)+mdr < 200204
group by navn

Then I get the error:
INVALID AGGREGATE REFERENCE.

So in short, I can't do this or ?

Michael