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: Lawrence Simela <lsimela_at_mahalini.prestel.co.uk>
Date: 1998/01/04
Message-ID: <68p23c$orn$1@svr-c-01.core.theplanet.net>#1/1

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

Original text of this message

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