pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Riccardo G. Facchini <abief_ag_-postgresql@yahoo.com>
To: pgsql-sql@postgresql.org
Subject: Re: case stement when null
Date: Fri, 18 Jun 2004 23:21:38 -0700 (PDT)
Message-ID: <20040619062138.5995.qmail@web13904.mail.yahoo.com> (raw)
In-Reply-To: <BAY8-F104oxRI8gcXIi0003bc86@hotmail.com>

--- Jaime Casanova <__> wrote:
> hi all,
> 
> Well i rethink my design 'cause the other was too slow. but all
> solutions 
> involves new problems... now my problem is with a function of this
> type:
> 
> 
> CREATE OR REPLACE FUNCTION
> "public"."rec_f_consultarplanificacionrubros" 
> (smallint, smallint, char(9), smallint, smallint, smallint, char(2))
> RETURNS 
> SETOF "public"."rec_td_rubrosplanificados" AS '
>     select rub_codigo, cpa_valor, cpa_fechavencimiento
>          from rec_m_cuadropagosciclo
> 		where ent_codigo = $1
> 		  and sec_codigo = $2
> 		  and ani_codigo = $3
> 		  and case $4
>                    when null then cic_codigo IN (select cic_codigo
> from 
> aca_m_cicloaniolectivo
>                                                         where
> ent_codigo = 
> $1
>                                                           and
> sec_codigo = 
> $2
>                                                           and
> ani_codigo = 
> $3)
>                    else cic_codigo = $4
>               end
> ' LANGUAGE 'sql'
> 
> but when $4 is null the function executes the else part and what i
> want to 
> do is to execute the when null. Can you help me???

try the form:

case
  when $4 is null
    then cic_codigo IN
         (select cic_codigo
            from aca_m_cicloaniolectivo
           where ent_codigo = $1 and
                 sec_codigo = $2 and
                 ani_codigo = $3)
    else cic_codigo = $4
end

[]

regards,



=====
Riccardo G. Facchini



view thread (3+ messages)  latest in thread

Message-ID: <20040619062138.5995.qmail@web13904.mail.yahoo.com>
Permalink:  ../20040619062138.5995.qmail@web13904.mail.yahoo.com/
Also on:    postgresql.org/message-id/20040619062138.5995.qmail@web13904.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: abief_ag_-postgresql@yahoo.com
  Subject: Re: case stement when null
  In-Reply-To: <20040619062138.5995.qmail@web13904.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox