From: Mark Gibson <gibsonm@cromwell.co.uk>
To: Richard Sydney-Smith <richard@ibisaustralia.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Implementation of a bag pattern using rules
Date: Mon, 09 Feb 2004 17:42:25 +0000
Message-ID: <4027C681.3090102@cromwell.co.uk> (raw)
In-Reply-To: <001b01c3ef1c$a3034890$cee98a90@athlon2000>
References: <40278022.5070408@cromwell.co.uk>
<001b01c3ef1c$a3034890$cee98a90@athlon2000>
Richard Sydney-Smith wrote:
>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.
>
>
>
I used to use functions for this kind of thing,
and was thinking that what SQL really needed was an 'UPDATE OR INSERT'
command,
then it suddenly came to me last night, it could be done with rules or
triggers.
[I've posted a trigger solution for the relative values separately, in
response to Tom Lanes help]
>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
>
>
>
Hmmm, yeah, I'm wondering about that one. It would be handy.
Custom datatype maybe - an integer with a flag to indicate absolute or
relative???
eg:
INSERT INTO bag_test VALUES ('orange', '10 abs');
INSERT INTO bag_test VALUES ('orange', '-5 rel');
or views that modify an underlying table???
eg:
INSERT INTO bag_test_abs VALUES ('orange', 10);
INSERT INTO bag_test_rel VALUES ('orange', -5);
I have no idea yet whether these are possible though, any ideas?
>Much of my attitude to triggers has been non-committal. Your example changes
>that.
>
>
>
Triggers, rules and functions ROCK. It's allowed us to move all the
business logic into the
database itself so we can create really simple clients easily in any
language/environment.
Right, I'm off home now :)
Cheers
--
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gibsonm@cromwell.co.uk, richard@ibisaustralia.com
Subject: Re: Implementation of a bag pattern using rules
In-Reply-To: <4027C681.3090102@cromwell.co.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox