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))
например:ако vgroupid = -1
, тогава последното условие ще бъде (((GROUPID = -1) AND (-1 > -1)) OR (-1 = -1))
или ((forever_false AND forever_false) OR (forever_true))
или (-1 = -1)
- всички записи
вместо това, ако vgroupid = 123
последното условие ще бъде (((GROUPID = 123) AND (123 > -1)) OR (123 = -1))
или (((GROUPID = 123) and forever_true) OR (forever_false))
или (GROUPID = 123)
- само 123 GROUPID