X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id CAD5011F6325 for ; Tue, 18 Apr 2006 16:14:44 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.599 X-Spam-Level: X-Spam-Status: No, score=-2.599 required=5 tests=[BAYES_00=-2.599, UPPERCASE_25_50=0] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id x7GEbMZX046T for ; Tue, 18 Apr 2006 16:14:28 -0300 (ADT) X-Greylist: delayed 00:32:10.7304 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id D906E11F6558 for ; Tue, 18 Apr 2006 16:14:27 -0300 (ADT) Received: from depot.mtholyoke.edu (depot.mtholyoke.edu [138.110.1.83]) by svr4.postgresql.org (Postfix) with ESMTP id 5B2815AF0AF for ; Tue, 18 Apr 2006 18:42:16 +0000 (GMT) Received: from ice.mtholyoke.edu (ice.mtholyoke.edu [138.110.1.25]) by depot.mtholyoke.edu (8.13.4/8.13.4/Debian-3sarge1) with ESMTP id k3IIgDSk026636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Apr 2006 14:42:13 -0400 Received: from yogi.mtholyoke.edu (yogi.mtholyoke.edu [138.110.1.26]) by ice.mtholyoke.edu (8.13.4/8.13.4/Debian-3) with ESMTP id k3IIgCIj032596 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Apr 2006 14:42:13 -0400 Received: from yogi.mtholyoke.edu (localhost [127.0.0.1]) by yogi.mtholyoke.edu (8.13.6/8.13.2/v20050819-1518) with ESMTP id k3IIgBlw017516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Apr 2006 14:42:11 -0400 Received: (from rpeterso@localhost) by yogi.mtholyoke.edu (8.13.6/8.13.4/Submit) id k3IIgAr8017507 for pgsql-sql@postgresql.org; Tue, 18 Apr 2006 14:42:10 -0400 From: Ron Peterson Date: Tue, 18 Apr 2006 14:42:10 -0400 To: pgsql-sql@postgresql.org Subject: create temp table in rule Message-ID: <20060418184209.GB31915@mtholyoke.edu> Mail-Followup-To: pgsql-sql@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: Mount Holyoke College X-Operating-System: Debian GNU/Linux User-Agent: Mutt/1.5.9i X-Scanned-By: MIMEDefang 2.52 on 138.110.1.180 X-Archive-Number: 200604/119 X-Sequence-Number: 24928 Is it possible to create a temporary table within a rule? I get a syntax error near 'CREATE TEMPORARY TABLE' if I try to do the following: CREATE RULE id_insert_rule AS ON INSERT TO id_insert DO INSTEAD ( CREATE TEMPORARY TABLE id_temp ( LIKE id ) ON COMMIT DELETE ROWS; INSERT INTO id_temp ( username, pass_md5, pass_sha1 ) VALUES new.username, encode( digest( new.password, 'md5' ), 'hex' ), encode( digest( new.password, 'sha1' ), 'hex' ); DELETE FROM id USING id_temp WHERE id.username = id_temp.username; INSERT INTO id SELECT * FROM id_temp; ); As you can see, I'm trying to create a simple 'insert or update' rule. -- Ron Peterson Network & Systems Manager Mount Holyoke College http://www.mtholyoke.edu/~rpeterso