X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CB333D1D841 for ; Tue, 3 Feb 2004 17:00:34 +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 17308-05 for ; Tue, 3 Feb 2004 13:00:25 -0400 (AST) Received: from web13809.mail.yahoo.com (web13809.mail.yahoo.com [216.136.175.217]) by svr1.postgresql.org (Postfix) with SMTP id 95082D1D2D0 for ; Tue, 3 Feb 2004 13:00:22 -0400 (AST) Message-ID: <20040203170018.79985.qmail@web13809.mail.yahoo.com> Received: from [216.173.173.66] by web13809.mail.yahoo.com via HTTP; Tue, 03 Feb 2004 09:00:18 PST Date: Tue, 3 Feb 2004 09:00:18 -0800 (PST) From: Chris Gamache Reply-To: cgg007@yahoo.com Subject: Re: Alternative to "Money" ... To: Harald Fuchs , pgsql-admin@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/30 X-Sequence-Number: 12204 Its coming through as a string. It has to be changed from a string sometime... I suppose I could put the alteration intelligence into the script that inserts the information into the DB. That would require rewriting a lot of application-side code. Besides, I'd rather have as much heavy lifing done with the (more robust) database as possible. That'll leave the weaker client able to handle its tasks better. Is this logic flawed? It can't be any worse than it is right now. I have my own casts for money->int2,int4,int8,float,float4,float8 so that the mathmatic operators, functions, and aggregates will operate properly. CG --- Harald Fuchs wrote: > In article <20040203160813.81708.qmail@web13808.mail.yahoo.com>, > Chris Gamache writes: > > > That does make more sense (cents? :) ). > > > View and rule still apply, tho. Better performance still? > > > create temporary table new_money (product text, cents int4); > > > create view v_new_money as select product, > (cents::numeric/100)::numeric(10,2) > > as dollars from new_money; > > > create rule v_new_money_upd as on update to v_new_money do instead update > > new_money set product=new.product, cents=new.dollars * 100 where product = > > old.product; > > > create rule v_new_money_del as on delete to v_new_money do instead delete > from > > new_money where product = old.product; > > > create rule v_new_money_ins as on insert to v_new_money do instead insert > into > > new_money (product, cents) values (new.product, new.dollars * 100); > > > insert into new_money (product, cents) values ('Flowbee','1995'); > > insert into new_money (product, cents) values ('Country Hits','995'); > > insert into v_new_money (product, dollars) values ('ThighMaster','39.95'); > > update v_new_money set dollars = '14.95' where product='Flowbee'; > > From where would you get this '14.95'? From your application? If > yes, what type is it? A string or a float? A string would be > inefficient (like SQLs NUMERIC), a float would not be exact (like SQLs > FLOAT). > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/