X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 4CE939DC8A7 for ; Mon, 16 Jan 2006 22:55:00 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05550-02 for ; Mon, 16 Jan 2006 22:55:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from a2s5.a2hosting.com (host-209-124-50-10.a2webhosting.com [209.124.50.10]) by postgresql.org (Postfix) with ESMTP id 3A9BB9DC8A4 for ; Mon, 16 Jan 2006 22:54:55 -0400 (AST) Received: from adsl-155-31-135.tys.bellsouth.net ([68.155.31.135] helo=[192.168.1.10]) by a2s5.a2hosting.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.52) id 1Eygzq-0003Ps-Of; Mon, 16 Jan 2006 21:54:58 -0500 In-Reply-To: <0IT700IG8S07GF90@VL-MO-MR002.ip.videotron.ca> References: <0IT700IG8S07GF90@VL-MO-MR002.ip.videotron.ca> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: "'pgsql-sql@postgresql.org' SQL" Content-Transfer-Encoding: 7bit From: John DeSoi Subject: Re: Executing plpgsql scripts using psql, is that possible? Date: Mon, 16 Jan 2006 21:54:55 -0500 To: Daniel CAUNE X-Mailer: Apple Mail (2.746.2) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s5.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.139 required=5 tests=[AWL=0.139] X-Spam-Score: 0.139 X-Spam-Level: X-Archive-Number: 200601/102 X-Sequence-Number: 23891 Daniel, On Jan 16, 2006, at 8:55 PM, Daniel CAUNE wrote: > Yes, but that requires creating a function while I would prefer not > having do so, as I said in my previous mail: "I mean, without > creating a function that wraps the whole, of course! :-)". Why? > Actually this is not a function; this is a script that inserts > static data into dimension tables such as Country, Language, etc. Sorry I misunderstood the question. > So, I completely understand that I can write an SQL script that: > > 1 - creates a function that wraps SQL code that inserts static > data into dimension tables. > 2 - executes that function > 3 - destroys that function > > But actually that is a bit weird, isn't it? \copy is the easiest way in psql to populate tables. If you need more control, maybe copy the data to temp tables and then write plpgsql as needed to insert the data into the final tables. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL