Hm, isn't already commited when/case/then/else syntax do the same?

No, not strictly. The "CASE WHEN" is an if *within* an expression:

  \set i CASE WHEN condition THEN val1 ELSE val2 END

The \if is at the script level, like psql already available version, which can change what SQL is sent.

  \if condition
    SOME SQL
  \else
    OTHER SQL
  \endif

You could achieve the CASE semantics with some \if:

  \if condition
    \set i val1
  \else
    \set i val2
  \endif

But the reverse is not possible.

--
Fabien.

Reply via email to