X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 218A4474E44 for ; Wed, 9 Apr 2003 15:09:51 -0400 (EDT) Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 58CE5474E42 for ; Wed, 9 Apr 2003 15:09:47 -0400 (EDT) Received: (qmail 6946 invoked from network); 9 Apr 2003 19:11:46 -0000 Received: from ns1.trade-india.com (HELO www.trade-india.com) (66.234.10.14) by infocom-236-129-del.trade-india.com with SMTP; 9 Apr 2003 19:11:46 -0000 Received: (qmail 9011 invoked by uid 99); 9 Apr 2003 19:09:13 -0000 Received: from 219.65.233.94 (SquirrelMail authenticated user mallah) by mail.trade-india.com with HTTP; Thu, 10 Apr 2003 00:39:13 +0530 (IST) Message-ID: <1461.219.65.233.94.1049915353.squirrel@mail.trade-india.com> Date: Thu, 10 Apr 2003 00:39:13 +0530 (IST) Subject: Re: Getting NEW and OLD in ordinary functions. From: To: In-Reply-To: <200304091123.16123.josh@agliodbs.com> References: <200304091551.02277.mallah@trade-india.com> <200304090945.45334.josh@agliodbs.com> <1321.219.65.233.94.1049911417.squirrel@mail.trade-india.com> <200304091123.16123.josh@agliodbs.com> X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Cc: X-Mailer: SquirrelMail (version 1.2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-24.7 required=5.0 tests=BAYES_10,IN_REP_TO,MISSING_MIMEOLE,MISSING_OUTLOOK_NAME, NO_REAL_NAME,QUOTED_EMAIL_TEXT,QUOTE_TWICE_1,REFERENCES, REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/146 X-Sequence-Number: 12847 > Rajesh, > >> could u pleeeeeez check my 50 LOC when u have some free time and commen= t on my questions I >> will be really grateful. > > SInce you asked so nicely ... Glad to hear again! > > I don't see anything wrong with your code, though I will of course be hap= py to help with > particular errors. And your general approach is fine. > > Two suggestions for improvement: > > 1) > >> This is also very interesting , when u time can u discuss it a bit more.= what does the locking >> scheme achieve? >> and how does "custom error messages " really help ? >> (maybe in a pvt mail if its not appropriate here) > > This will be the subject for an "Adventures in PostgreSQL" article if I e= ver get my website up > ... > > IF listing_status NOT IN (''ACTIVE'', ''DELETED'', > ''EXPIRED_BY_SYSTEM'') THEN > RAISE EXCEPTION '' listing_status has to be ACTIVE,DELETED= or > EXPIRED_BY_SYSTEM for profile_id=3D%'' , profile_id; > END IF ; > > IF hosting_status NOT IN (''TEMPORARY'', ''COMPLETE'') THEN > RAISE EXCEPTION '' hosting_status has to be TEMPORARY or > COMPLETE for profile_id=3D%'' , profile_id; > END IF ; > > These two constraints might be better handled by Foriegn Keys to an appr= opriate reference list > (personally, I don't use check constraints at all ... I find FKs vastly = easier to manage.) This was for simulating CHECK (column in ('A','B' , 'C')) ; I already have 5 FKEYS on that table dont' u feel fkeys for this purpose is an overkill? eg here the valid values can range from say 3 to 10 (small number) whereas FKEYS are capable to check in a very large set residing in another table. also fkeys makes updates and inserts slower (i feel) another question i have seen CHECK traslating IN to a set of ORs does the same happen in pl/pgsql internally? and does it really matter for here for small target sets? > > Second, it would be more user-friendly if you concatinated all error mess= ages and delivered a > list of *all* problems to the user in the exception message, rather than= one at a time. Thanks for this , > Imagine a user who fixed his listing status, only to get an error messag= e about hosting > status, and then to get an error message about online sales. true this is particularly valid in www environments. Regds MAllah. > > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco ----------------------------------------- Get your free web based email at trade-india.com. "India's Leading B2B eMarketplace.!" http://www.trade-india.com/