259 | | Alternatywnie, jeśli chcemy pozostawić historię wykonanych czynności na procedurze możemy usunąć etapy, które nie były użyte w procedurze i pozostawić tylko wykonane etapy. |
260 | | |
261 | | {{{ |
262 | | DELETE |
263 | | FROM stages |
264 | | WHERE sop_id = any |
265 | | (SELECT sop_id |
266 | | FROM stages s |
267 | | JOIN procedures p USING(procid) |
268 | | WHERE NOT (s.is_act |
269 | | OR s.is_fix) |
270 | | AND (p.comple |
271 | | OR p.cancel) |
272 | | ORDER BY p.adddat ASC) |
273 | | }}} |
274 | | |
275 | | Procedury z odpiętych dokumentów, spraw |
276 | | {{{ |
277 | | DELETE FROM procedures p WHERE NOT EXISTS |
278 | | (SELECT d.procid FROM documents d |
279 | | WHERE p.procid = d.procid AND d.procid IS NOT NULL) AND |
280 | | prtpcl = 'Document' |
281 | | AND p.procid = p.rootpr |
282 | | }}} |
| 259 | Procedury z odpiętych dokumentów |
| 260 | {{{ |
| 261 | DELETE FROM procedures p |
| 262 | WHERE p.ctxcls = 'DOCUMENT' AND p.rootpr = p.procid AND p.procid NOT IN (SELECT procid FROM documents WHERE procid IS NOT NULL AND gostof IS NULL); |
| 263 | }}} |
| 264 | |
| 265 | Procedury z odpiętych dokumentów |
| 266 | {{{ |
| 267 | DELETE FROM procedures p |
| 268 | WHERE p.ctxcls = 'PROCESS' AND p.rootpr = p.procid AND p.procid NOT IN (SELECT procid FROM processes WHERE procid IS NOT NULL AND gostof IS NULL); |
| 269 | }}} |