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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Determining the defined maximum length of a VARCHAR field

Re: Determining the defined maximum length of a VARCHAR field

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Wed, 12 Mar 2003 08:44:05 -0800
Message-ID: <3E6F63D5.B6CC7A64@exesolutions.com>


Michael Young wrote:

> Is there an easy way to determine the defined length of a
> VARCHAR/VARCHAR2 field in Oracle SQL? I write a lot of interfaces
> that import data, and many times I'd like to simply truncate the
> incoming text data to the length of the existing varchar column in a
> table. I know I can query 'user_tab_columns', but it seems that there
> should be a built-in function that takes the table name and the
> varchar column name and returns the defined maximum length for the
> column.

In PL/SQL variables should almost never be defined as VARCHAR2, and never as VARCHAR.

Never VARCHAR because Oracle makes no promise to support it in the future. Almost never VARCHAR2 because any VARCHAR2 that relates to a columns should be defined as table_name.column_name%TYPE.

This not only eliminates the need to know the size ... it eliminates the possibility of an application breaking if the column size is altered.

Daniel Morgan Received on Wed Mar 12 2003 - 10:44:05 CST

Original text of this message

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