Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 74A5A9FB3E7 for ; Thu, 10 May 2007 03:04:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 81764-06 for ; Thu, 10 May 2007 03:04:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from rrmailscan3.safenetbox.biz (unknown [203.25.40.75]) by postgresql.org (Postfix) with ESMTP id 1D51B9FA38B for ; Thu, 10 May 2007 03:04:09 -0300 (ADT) Received: from rrmailscan3.safenetbox.biz (rrmailscan3.safenetbox.biz [127.0.0.1]) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 97E5E1D484A0 for ; Thu, 10 May 2007 16:04:07 +1000 (EST) Received: from [127.0.0.1] (online4-new.lnk.telstra.net [139.130.169.227]) (Authenticated sender: remote) by rrmailscan3.safenetbox.biz (Postfix) with ESMTP id 5D19E1D4849F for ; Thu, 10 May 2007 16:04:06 +1000 (EST) Message-ID: <4642B5C9.5000505@autoledgers.com.au> Date: Thu, 10 May 2007 14:03:53 +0800 From: Paul Lambert User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Passing input to a view? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/74 X-Sequence-Number: 28354 Is it possible to define a view to use input parameters rather than a hard-wired value in a where clause? I.e. I have the following view: CREATE OR REPLACE VIEW invoiced_repairs AS SELECT ro_header.ro_number, ro_header.received_date, vehicles.vehicle_id, vehicles.model, vehicles.engine, vehicles.transmission, ro_header.odometer_reading, ro_header.service_description, ( CASE WHEN (vehicles.month_of_manufacture <> '' AND vehicles.year_of_manufacture <> '') THEN (vehicles.month_of_manufacture || '/' || vehicles.year_of_manufacture) ELSE '' END ) AS date_of_manufacture, vehicles.identification_number, vehicles.engine_number from ro_header INNER JOIN vehicles USING (vehicle_address) WHERE ro_header.received_date between '1-jan-2007' AND '10-May-2007'; ALTER TABLE invoiced_repairs OWNER TO postgres; Instead of having it set to 1-Jan-2007 and 10-May-2007 for the dates, can I specify that those values should be passed to the view? Or would I need to change this to an SQL language function? I can't find anything in the documentation that answers this, but maybe I'm not looking hard enough. Thanks in advance. -- Paul Lambert Database Administrator AutoLedgers