converting chars to varchar2's. Please help

From: DINESH PUNJABI <dpunjabi_at_nyx10.cs.du.edu>
Date: 1995/08/16
Message-ID: <40td13$2tr_at_nyx10.cs.du.edu>#1/1


Greetings,

Can a char field be converted into a varchar2 field. I am trying to build a view containing varchar2 fields. The tables used to build the view contain char fields. Is there a way to convert this to a varchar2 (like within a select statement).

I tried using to_char, but it will only work if the source field (the 'from' field) is either a number, date or a char field with numeric information. In other words, to_char won't convert a char field containing ascii, etc. data.

Also, it seems that there is a PL/SQL function under oracle called 'TO_VARCHAR2'. Unfortunately, I cannot invoke this under sqlplus since it gives me an error. Your email will be highly appreciated.

Rgds

Dinesh



Sample test:

SQL> desc dinesh_test

 Name                            Null?    Type
 ------------------------------- -------- ----
 COL1                                     NUMBER(38)
 COL2                                     CHAR(10)

SQL> select * from dinesh_test;

      COL1 COL2
---------- ----------

     12345 HELLO1 SQL> select to_varchar2(col2) from dinesh_test; select to_varchar2(col2) from dinesh_test

       *
ERROR at line 1:
ORA-00904: invalid column name

SQL>


-- 

Dinesh Punjabi 
dpunjabi_at_nyx.cs.du.edu                Work: (303)-624-9812
Received on Wed Aug 16 1995 - 00:00:00 CEST

Original text of this message