Dynamic WHERE can be empty

 home  single file   example  edit

dynamic_where_empty

Description

Reports a dynamic WHERE (lv) whose variable can reach the statement empty

Extended Information

An empty dynamic WHERE is no condition: SELECT and OPEN CURSOR read the whole table,
DELETE FROM, UPDATE and MODIFY FROM ( SELECT ... ) change every row.

Checked are SELECT, OPEN CURSOR, DELETE FROM, UPDATE and MODIFY FROM ( SELECT ... ) whose WHERE is a single
dynamic token (lv), lv being a local variable of the method, form or function module, declared by DATA without
VALUE (or with VALUE IS INITIAL or an empty literal).

The statement is reported when no path through the procedure before the statement definitely gives lv a value,
ie. every assignment to lv sits in a conditional block (IF without ELSE, a branch of an IF or CASE where not all
branches assign, a LOOP, WHILE, DO or SELECT loop body, which can run zero times, a TRY block).

Not reported:

* a WHERE with a static condition besides the dynamic token, eg. WHERE mandt = @sy-mandt AND (lv)
* an unconditional assignment to lv before the statement, other than CLEAR or an empty literal
* a guard on lv: IF lv IS INITIAL with RETURN, EXIT, RAISE etc. before the statement,
CHECK lv IS NOT INITIAL, ASSERT lv IS NOT INITIAL, or the statement inside IF lv IS NOT INITIAL
* UP TO n ROWS, see option skipUpTo
* lv being a parameter, attribute or call result, or lv passed to PERFORM, CALL FUNCTION, ASSIGN or a reference,
as the value is not known
* procedures containing macros

Subqueries are not checked.

Default Configuration

Hover to see descriptions, Ctrl+Space for suggestions

Examples