Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id C77BB9F94F7 for ; Tue, 21 Aug 2007 12:33:44 -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 72527-04 for ; Tue, 21 Aug 2007 12:33:40 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.189]) by postgresql.org (Postfix) with ESMTP id ED8739F978D for ; Tue, 21 Aug 2007 12:33:39 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id l15so1189809rvb for ; Tue, 21 Aug 2007 08:33:39 -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=ry8+WgfdFLuiRtHtt0K0S3mU3OkVsOMUfZRN8E2xms1BxtT31L0lboU6BibNtfGepZ6Du7fP+O2vzj7HlD0E1yJB558h9KzpP8VbjPxGj5sahRXwyUuX5SwiAy85I8OlgTXVO9zYWzFI7UHZ7nFrbvmtuG9Aoed6/JdFR5FMBGc= 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=PT7K9wTITZ7yfoioMqhzfrt/aEc3zJCGbUhFq3l5x4Vmz6Z+F/KyztW6HgZ7IN/oPAVryyQQyHiBAGN6Mjy5YhGo3EqtAmWdi+p4AsZ5ZRfYTYCaPVg060VxMM2omTKjIFMsGmJERu+01dROOXDTHZ9rAh+lultdzHM6vII5Ij4= Received: by 10.141.3.10 with SMTP id f10mr3451952rvi.1187710418840; Tue, 21 Aug 2007 08:33:38 -0700 (PDT) Received: by 10.141.98.12 with HTTP; Tue, 21 Aug 2007 08:33:38 -0700 (PDT) Message-ID: Date: Tue, 21 Aug 2007 10:33:38 -0500 From: "Scott Marlowe" To: "Chris Hoover" Subject: Re: How to export query results Cc: "pgsql-admin@postgresql.org Admin" In-Reply-To: <1d219a6f0708210754v456fecaer68d0420cf2526c12@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1d219a6f0708210754v456fecaer68d0420cf2526c12@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/253 X-Sequence-Number: 26584 On 8/21/07, Chris Hoover wrote: > I need some guidance. > > I need to have an after insert trigger execute on a specific table and > export the results of query to a file on the database file system. Is this > possible to do from a trigger? If so, how can I accomplish this? I am > drawing a blank on how to export the results of the query. Yes. you need to use the copy command inside a function and use security definer to say that the function runs as a superuser.