Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 5DAD71F22147 for ; Sat, 12 Nov 2011 06:01:56 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 22322-06 for ; Sat, 12 Nov 2011 10:01:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 4377C1F22146 for ; Sat, 12 Nov 2011 06:01:48 -0400 (AST) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RPAPD-00062w-6n for pgsql-sql@postgresql.org; Sat, 12 Nov 2011 11:01:47 +0100 Received: from ip-118-90-23-26.xdsl.xnet.co.nz ([118.90.23.26]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 12 Nov 2011 11:01:47 +0100 Received: from jasen by ip-118-90-23-26.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 12 Nov 2011 11:01:47 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: Partitionning + Trigger and Execute not working as expected Date: 12 Nov 2011 09:56:02 GMT Organization: Dis (not Dat) Organisation Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-23-26.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/57 X-Sequence-Number: 36030 On 2011-11-08, Sylvain Mougenot wrote: > --f46d043c7fbad4a6b104b1357041 > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: quoted-printable > > Hello, > I'm trying to use table partitionning on a table called JOB. > Each month a new table is created to contain the rows created on that month= > . > ex : JOB_2011_11 for rows created during november 2011. > > To do that I followed this advices on that page : > http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html > I also would like to create code dynamically into the trigger in order to > have all "INSERT INTO" inheritated tables (tables like JOB_YYYY_MM) queries > done. > > But I can't make it work. I've an error when the insert is done using > EXECUTE. > *Working :* INSERT INTO job_2011_11 values (NEW.*); > *Not Woking : *EXECUTE 'INSERT INTO '|| currentTableName || ' values > (NEW.*)'; > > Could someone tell me how to make this EXECUTE work? EXECUTE 'INSERT INTO '|| currentTableName || ' select ('||quote_literal(NEW)||'::job%ROWTYPE).*'; or EXECUTE 'INSERT INTO '|| currentTableName || ' values ($1.*)' USING NEW; -- ⚂⚃ 100% natural