CURSOR c
IS
SELECT COMPANYID,
GROUPID,
PERIODID,
FN_PPROCESSCURRENT
FROM LIQUIDATIONSDETAILS
WHERE PROCESSID = FN_PPROCESSPREVIOUS
AND (UNCOLLECTED > 0 OR INVOICE = 0)
AND (((GROUPID = vgroupid) AND (vgroupid > -1)) OR (vgroupid = -1))
por ejemplo:si vgroupid = -1
, entonces la última condición será (((GROUPID = -1) AND (-1 > -1)) OR (-1 = -1))
o ((forever_false AND forever_false) OR (forever_true))
o (-1 = -1)
- todos los registros
en cambio, si vgroupid = 123
la última condición será (((GROUPID = 123) AND (123 > -1)) OR (123 = -1))
o (((GROUPID = 123) and forever_true) OR (forever_false))
o (GROUPID = 123)
- solo 123 GRUPOS