X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C5450D1E9AF for ; Mon, 1 Mar 2004 16:40:39 +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 95229-08 for ; Mon, 1 Mar 2004 12:40:35 -0400 (AST) Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net [66.167.251.6]) by svr1.postgresql.org (Postfix) with ESMTP id CF28BD1E9AD for ; Mon, 1 Mar 2004 12:40:34 -0400 (AST) Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP id C448969A71; Mon, 1 Mar 2004 11:40:32 -0500 (EST) Message-ID: <4043677D.6040905@potentialtech.com> Date: Mon, 01 Mar 2004 11:40:29 -0500 From: Bill Moran User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "scott.marlowe" Cc: Rajat Katyal , pgsql-general@postgresql.org Subject: Re: value too long error References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/23 X-Sequence-Number: 58067 scott.marlowe wrote: > On Sat, 28 Feb 2004, Rajat Katyal wrote: > >>Hi: >> >>Whenever i try to insert the data, size of which is greater than that of column datatype size, I got the exception value too long for..... >> >>However this was not in postgresql7.2. >> >>Can anyone please tell me, is there any way so that i wont get this exception. Please help me as soon as possible > > As mentioned earlier, this is against spec (and for good reason, > databases, by default, shouldn't just toss away data that doesn't fit, > they should throw an error and prevent accidental data loss.) > > That said, the easiest way to do this is to make the field a text type, > not a limited varchar, then create a before trigger that uses substring to > chop all but the first x characters and insert them. (This just seemed like a good time to do a brain-dump) I was thinking about this question, and the various answers. In OO programming, the generally accepted rule is that a program shouldn't access class values directly, but the class should have methods to set and retrieve the data. This allows internal representations to change without affecting the public API of the class. It also allows data validation to occur, if needed. I'm just wondering how far this rule of thumb could/should be extended to databases? I mean, you could say: "Nobody does a direct INSERT, but always calls a stored procedure that stores the result." I don't know how much this might break the mindset of the client developer. Anyway, it's one possible solution to the problem. But (to me) it's a potentially new way of looking at things. -- Bill Moran Potential Technologies http://www.potentialtech.com