当我尝试执行过程时,它说无效使用了聚合函数或OLAP函数。 SQLCODE = -120
FOR v AS cur1 CURSOR FOR
SELECT SOURCE_TRANSACTION_KEY,MONTHLY_ENTRIES, MONTHLY_EXITS, TRANSIENT_ENTRIES, TRANSIENT_EXITS, SPACE_COUNT, WORKING_CAPACITY, DATETIME
FROM DATAMART.OCCUPANCY_STAGE WHERE (DATETIME BETWEEN LAST_RESET_DATE AND CURRENT_TIMESTAMP) AND LOCATION_KEY = FIND_LOCATION_KEY ORDER BY DATETIME ASC
DO
SET TM_MONTHLY_PARKERS_ON_LOT = sum(OK_MONTHLY_PARKERS_ON_LOT + v.MONTHLY_ENTRIES - MONTHLY_EXITS);
SET TM_TRANSIENT_PARKERS_ON_LOT = sum(OK_TRANSIENT_PARKERS_ON_LOT + v.TRANSIENT_ENTRIES - TRANSIENT_EXITS);
SET TM_AVAILABLE_SPACES = sum(v.SPACE_COUNT - TM_MONTHLY_PARKERS_ON_LOT - TM_TRANSIENT_PARKERS_ON_LOT);
SET TM_OCCUPANCY_PERCENT = (sum(TM_MONTHLY_PARKERS_ON_LOT + TM_TRANSIENT_PARKERS_ON_LOT)) / v.WORKING_CAPACITY;
SET TM_CARS_ON_LOT = sum(TM_MONTHLY_PARKERS_ON_LOT + TM_TRANSIENT_PARKERS_ON_LOT);
SET TM_SOURCE_TRANSACTION_KEY = v.SOURCE_TRANSACTION_KEY;
SET TM_DATETIME = v.DATETIME;
SET OK_MONTHLY_PARKERS_ON_LOT = TM_MONTHLY_PARKERS_ON_LOT;
SET OK_TRANSIENT_PARKERS_ON_LOT = TM_TRANSIENT_PARKERS_ON_LOT;
UPDATE DATAMART.OCCUPANCY_STAGE SET MONTHLY_PARKERS_ON_LOT = TM_MONTHLY_PARKERS_ON_LOT, TRANSIENT_PARKERS_ON_LOT = TM_TRANSIENT_PARKERS_ON_LOT,
AVAILABLE_SPACES = TM_AVAILABLE_SPACES, OCCUPANCY_PERCENT = TM_OCCUPANCY_PERCENT, CARS_ON_LOT = TM_CARS_ON_LOT, IS_PROCESSED_FLAG = 0 WHERE
LOCATION_KEY = FIND_LOCATION_KEY AND SOURCE_TRANSACTION_KEY = TM_SOURCE_TRANSACTION_KEY AND DATETIME = TM_DATETIME;
END FOR;