data type for substr

data type for substr

Post by xix » Sun, 22 Jun 2003 07:21:30



hi , i am using db2 udb v8.1 on NT.

if i have field substr on a varchar type field, what will be the data
type for this field, i check it is char type, why is that?

 
 
 

data type for substr

Post by Blair Adamach » Sun, 22 Jun 2003 10:58:45


If you're asking for a substring, you know exactly how many bytes will be
returned, so CHAR makes more sense than VARCHAR (and is easier to work
with). This is explained in the SQL Reference in the chapter on functions
(see Table 16 is you're on DB2 v7).

If you want a varchar, you can always cast it back:

     select varchar(substr(col1,10,5)) from testvar


> hi , i am using db2 udb v8.1 on NT.

> if i have field substr on a varchar type field, what will be the data
> type for this field, i check it is char type, why is that?