X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 14EB9D1B2D9 for ; Fri, 18 Jun 2004 18:38:36 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22327-03 for ; Fri, 18 Jun 2004 21:38:29 +0000 (GMT) Received: from hotmail.com (bay8-f104.bay8.hotmail.com [64.4.27.104]) by svr1.postgresql.org (Postfix) with ESMTP id ECA34D1B20D for ; Fri, 18 Jun 2004 18:38:26 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Fri, 18 Jun 2004 14:38:28 -0700 Received: from 69.65.137.210 by by8fd.bay8.hotmail.msn.com with HTTP; Fri, 18 Jun 2004 21:38:28 GMT X-Originating-IP: [69.65.137.210] X-Originating-Email: [el_vigia_ec@hotmail.com] X-Sender: el_vigia_ec@hotmail.com From: "Jaime Casanova" To: pgsql-sql@postgresql.org Subject: case stement when null Date: Fri, 18 Jun 2004 21:38:28 +0000 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 18 Jun 2004 21:38:28.0360 (UTC) FILETIME=[97C21080:01C4557C] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/160 X-Sequence-Number: 18105 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??? Thanx in advance, Jaime Casanova _________________________________________________________________ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail