From: | Bill Moran <wmoran(at)potentialtech(dot)com> |
---|---|
To: | "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com> |
Cc: | Rajat Katyal <rajatk(at)intelesoftech(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: value too long error |
Date: | 2004-03-01 16:40:29 |
Message-ID: | 4043677D.6040905@potentialtech.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Shawn Harrison | 2004-03-01 17:09:32 | Database metadata queries (WAS Re: Moving from MySQL to PGSQL....some questions) |
Previous Message | scott.marlowe | 2004-03-01 16:19:03 | Re: installation -- help ? |