X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 9E5A5D1CCBE for ; Mon, 9 Feb 2004 14:52:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 60561-07 for ; Mon, 9 Feb 2004 10:52:51 -0400 (AST) Received: from server146.hostingrevolution.com (server146.hostingrevolution.com [64.21.143.245]) by svr1.postgresql.org (Postfix) with ESMTP id 50BC5D1C9B4 for ; Mon, 9 Feb 2004 10:52:41 -0400 (AST) Received: from [144.138.233.206] (helo=athlon2000) by server146.hostingrevolution.com with smtp (Exim 4.24) id 1AqCly-0006yU-Si; Mon, 09 Feb 2004 08:52:09 -0600 Message-ID: <001b01c3ef1c$a3034890$cee98a90@athlon2000> From: "Richard Sydney-Smith" To: "Mark Gibson" , References: <40278022.5070408@cromwell.co.uk> Subject: Re: Implementation of a bag pattern using rules Date: Mon, 9 Feb 2004 22:54:33 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server146.hostingrevolution.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - ibisaustralia.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/81 X-Sequence-Number: 16772 Mark, love the idea, guess I should have read it somewhere but haven't. Obvious and beautiful. Please let me know if you or someone else solves the initial double value. Got me thinking of all the places I cold have used this instead of coding select/insert/update/delete. Also have you worked a solutions where both the abs and relative inserts apply to the same bag eg insert another apple vs set apples to 5 Much of my attitude to triggers has been non-committal. Your example changes that. Well thanks again Richard Sydney-Smith ----- Original Message ----- From: "Mark Gibson" To: Sent: Monday, February 09, 2004 8:42 PM Subject: [SQL] Implementation of a bag pattern using rules > Hello, > I've been playing around with a simple solution for a bag or sparse > matrix using rules, > but have encountered a few problems I wish to discuss. > The bag pattern is commonly used for shopping baskets (item => quantity). > This sollution can also be used for a sparse matrix too (row,col => value). > > Example: