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

Home -> Community -> Usenet -> c.d.o.server -> Re: "Safe" copying from one table column to another

Re: "Safe" copying from one table column to another

From: Joseph S. Testa <jtesta_at_scioto.net>
Date: 1998/01/04
Message-ID: <34AF99E5.96AF20A0@scioto.net>#1/1

gerald_klima_at_maxmobil.at wrote:

> While writing a small PL/SQL program (ORACLE 7.3) I encountered the
> following problem: How do I copy a VARCHAR2 field from one table column
> to another, assuming that the two columns can be of different length and
> I don't want to hardcode the column lengths in my sourcecode (I don't
> want to change my sourcecode if the column definitions change). e.g.
> emp1.name is defined as VARCHAR2(30) emp2.name is defined as VARCHAR2(20)
> and I want to copy emp1.name into emp2.name (which of course raises a
> VALUE ERROR upon direct assignment if LENGTH(emp1.name) > 20), with
> emp1.name truncated on the right. I could not find any SQL function which
> returns the defined maximum length of a VARCHAR2 datatype.
>

max varchar2 size for oracle 7 is 2K, for oracle8 is 4K.

to find out the "length" of that data use the length command. to find out the size of the field definition get it from user_tab_columns.

joe

--
Joseph S. Testa, Oracle Database Administrator, mailto:jtesta_at_scioto.net
(home)
Vice-President Ohio Oracle Users Group,
See the Oracle FAQ at http://www.orafaq.org
Try http://web.scioto.net/jtesta that is also the place to find the FREE,
drop column script
ICQ UIN:  2832230(&oracle, home).
Received on Sun Jan 04 1998 - 00:00:00 CST

Original text of this message

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