pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bill Moran <wmoran@potentialtech.com>
To: scott.marlowe <scott.marlowe@ihs.com>
Cc: Rajat Katyal <rajatk@intelesoftech.com>
Cc: pgsql-general@postgresql.org
Subject: Re: value too long error
Date: Mon, 01 Mar 2004 11:40:29 -0500
Message-ID: <4043677D.6040905@potentialtech.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0403010859450.32148-100000@css120.ihs.com>
References: <Pine.LNX.4.33.0403010859450.32148-100000@css120.ihs.com>

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




view thread (10+ messages)  latest in thread

Message-ID: <4043677D.6040905@potentialtech.com>
Permalink:  ../4043677D.6040905@potentialtech.com/
Also on:    postgresql.org/message-id/4043677D.6040905@potentialtech.com

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: wmoran@potentialtech.com, scott.marlowe@ihs.com, rajatk@intelesoftech.com
  Subject: Re: value too long error
  In-Reply-To: <4043677D.6040905@potentialtech.com>
  References: <Pine.LNX.4.33.0403010859450.32148-100000@css120.ihs.com> <4043677D.6040905@potentialtech.com>

* 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