79195824

Date: 2024-11-16 18:36:53
Score: 0.5
Natty:
Report link

Actually, it is not skipped but it causes the concatenation to fail silently.

  1. X is NULL.

  2. When you do '|| X ||', the NULL value of X is not treated as a string but as a missing value.

  3. String concatenation with NULL ('|| NULL ||') results in the entire concatenation expression becoming NULL.

    Thus, the v_sql assignment evaluates to NULL, and you see NVL(,NULL) in your result

    If you want the literal text NULL to appear in the SQL query when X is NULL, you need to explicitly handle this substitution. For example:

    v_sql := 'insert into users(id) values(NVL(' || CASE WHEN X IS NULL THEN 'NULL' ELSE X END || ', NULL))';

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Jan Suchanek