Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: "Safe" copying from one table column to another
Surely you could define your variables as
v_emp1 emp1.name%TYPE;
v_emp2 emp2.name%TYPE;
as far as column lengths go I think you ought to set them to the maximun
they are likely to be. The database definition should not need to be
changed to change lengths every so often etc...the design should capture the
maximun lengths possible ... and in any case why can't the two lengths be
the same on the tables if they will be copied onto each other. They are the
same essentially..
Hope this helps
Lawrence Simela
MAHALINI CONSULTING LIMITED
gerald_klima_at_maxmobil.at wrote in message
<883783341.190185481_at_dejanews.com>...
>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.
>
>Gerald
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
Received on Sun Jan 04 1998 - 00:00:00 CST
![]() |
![]() |