Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 6909B9FA36A for ; Wed, 18 Jul 2007 01:50:05 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 80161-02 for ; Wed, 18 Jul 2007 01:50:00 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.245]) by postgresql.org (Postfix) with ESMTP id A24669FB667 for ; Wed, 18 Jul 2007 01:50:01 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id c36so13744ana for ; Tue, 17 Jul 2007 21:50:00 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lVgfLjZHMZEdTTwJKtlgLLZYEFxAICL/iHqAb/ZB3hC6osCFDqFRwjogXUpX1f4b+QylA9lv6rlXYWIrlw5UbC6ZW2Yu1jadfbErZh4wbaW2Du4SUWT+gmAJZUpUxti4AfL3PzXIk5D8EQt4v8osV4D5psS6DjixkCo089M1cHU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=POwFOYsWJ3Y9vunGBMH1qD4L/Ri1svS3XFP/gs+b3Z4TiJ7tCvWsPjG2AzqHkyQZ6uboyL3/GDaj7+RNl3JQIFYrrWUHC7AQYARjkqSizBBULV31K+tNqI893cIb2TvrEnMJaBI7Q4dGX/zoZW1UOQYvg/iMX3y1X3k26jokC5E= Received: by 10.100.153.17 with SMTP id a17mr753113ane.1184734200893; Tue, 17 Jul 2007 21:50:00 -0700 (PDT) Received: by 10.100.45.15 with HTTP; Tue, 17 Jul 2007 21:50:00 -0700 (PDT) Message-ID: Date: Tue, 17 Jul 2007 23:50:00 -0500 From: "Jaime Casanova" To: "Norm Garand" Subject: Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code Cc: pgsql-sql@postgresql.org In-Reply-To: <52149.39195.qm@web88311.mail.re4.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <52149.39195.qm@web88311.mail.re4.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/108 X-Sequence-Number: 28843 On 7/17/07, Norm Garand wrote: > In the WHERE portion of the SELECT statment, I'd like to insert the IF statement shown below. I've > tried single and double quotes and the pipeline for concatenation, but nothing seems to work. Any > suggestions or resolutions would be greatly appreciated. Please feel free to contact me directly. > use CASE baan=# create function t(con_stock boolean) returns setof ttdinv001214 as $$ baan$# select * from ttdinv001214 baan$# where substring(trim(t_item), 1, 3) = 'DPP' baan$# and case $1 when true then t_stoc > 0 else t_stoc = 0 end; baan$# $$ language sql; CREATE FUNCTION -- regards, Jaime Casanova "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs and the universe trying to produce bigger and better idiots. So far, the universe is winning." Richard Cook