Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Varchar truncating question

Re: Varchar truncating question

From: Stefan Grundmann <s.grundmann_at_t-online.de>
Date: Mon, 28 Aug 2000 19:37:07 +0200
Message-ID: <8oe8at$oq8$13$1@news.t-online.com>

Hi!

AFAIK there's no such option.

An alternative is to write a trigger that's truncates the varchar's to specfied length.

create or replace
trigger tr_on_table_xyz
on insert and update
for each row
begin

   :NEW.column1:= substr(:NEW.column1, 1, spec_length_column1);    :NEW.column2:= substr(:NEW.column2, 1, spec_length_column2);    ...
end;
/

Repeat this for all columns of your table.

Hope this helps,
Stefan.

<bcliff_at_my-deja.com> schrieb in im Newsbeitrag: 8oe020$bah$1_at_nnrp1.deja.com...
> Is there any way to get oracle to automatically truncate an entry into a
> varchar column if the entry is longer than the specified length?
> Currently, oracle will return an error. What I'm really looking for is
> a flag to set so that oracle truncates by default instead of returning
> an error. Thanks.
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Mon Aug 28 2000 - 12:37:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US