Re: a bug in plpgsql - Mailing list pgsql-bugs

From Tom Lane
Subject Re: a bug in plpgsql
Date
Msg-id 28336.1099597660@sss.pgh.pa.us
Whole thread Raw
In response to a bug in plpgsql  (Jaime Casanova <systemguards@yahoo.com>)
Responses Re: a bug in plpgsql
List pgsql-bugs
Jaime Casanova <systemguards@yahoo.com> writes:
>                 CASE rs_dtran.fpg_codigo
>                     WHEN ''EF'' THEN
>                         IF rs_ttran.tra_tipo = ''+'' THEN
>                             valor_ef := valor_ef + rs_dtran.dtr_valor;
>                         ELSE
>                             valor_ef := valor_ef - rs_dtran.dtr_valor;
>                         END IF;
>                     WHEN ''CH'' THEN
>                         IF rs_ttran.tra_tipo = ''+'' THEN
>                             valor_ch := valor_ch + rs_dtran.dtr_valor;
>                         ELSE
>                             valor_ch := valor_ch - rs_dtran.dtr_valor;
>                         END IF;
>                 END;

> but in that line there is a valid IF .. THEN .. ELSE
> block.

if/then/else is a statement, not a component of an expression.
CASE is an expression construct, not a statement.  I think
you need to rewrite the CASE as an if/then/elsif statement.

            regards, tom lane

pgsql-bugs by date:

Previous
From: Jaime Casanova
Date:
Subject: a bug in plpgsql
Next
From: Jaime Casanova
Date:
Subject: Re: a bug in plpgsql