Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 975ED2E32C3 for ; Thu, 6 Dec 2007 18:03:34 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 05210-03-2 for ; Thu, 6 Dec 2007 18:03:28 -0400 (AST) Received: from smtp116.iad.emailsrvr.com (smtp116.iad.emailsrvr.com [207.97.245.116]) by postgresql.org (Postfix) with ESMTP id 9D3522E018F for ; Thu, 6 Dec 2007 18:03:28 -0400 (AST) Received: from relay1.r1.iad.emailsrvr.com (localhost [127.0.0.1]) by relay1.r1.iad.emailsrvr.com (SMTP Server) with ESMTP id 9ABAE45385D for ; Thu, 6 Dec 2007 17:03:27 -0500 (EST) Received: by relay1.r1.iad.emailsrvr.com (Authenticated sender: erik-AT-myemma.com) with ESMTP id 81C69452DFE for ; Thu, 6 Dec 2007 17:03:27 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v752.3) Content-Transfer-Encoding: quoted-printable Message-Id: Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed To: pgsql-sql From: Erik Jones Subject: Rule rewrite to possible union? Date: Thu, 6 Dec 2007 16:03:22 -0600 X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/21 X-Sequence-Number: 29713 Here's what I'd like to happen, but I'm not seeing how it can be done. Say we have this simple table: CREATE TABLE foo ( id integer, foo varchar ); and then many tables along these lines: CREATE TABLE ud1_foo (LIKE foo); CREATE TABLE ud2_foo (LIKE foo); What I'd like is to do is select against foo and if there is an id in =20= the where clause equal to 1 or 2 add a union with the appropriate =20 table. I could easily do this at the application level, but this is =20 for a migration (the ud tables are going away) and I'd like to =20 minimize the number of transient application code changes wherever =20 possible. Is there any way I can make this happen? Erik Jones Software Developer | Emma=AE erik@myemma.com 800.595.4401 or 615.292.5888 615.292.0777 (fax) Emma helps organizations everywhere communicate & market in style. Visit us online at http://www.myemma.com