I am trying to insert into varchar2 column from a long column. here is the below example, TEXT.TEXT_COL = VARCHAR2(4000)
and NOTE.TEXT_NOTE = LONG
.
Converting from long
to varchar2
right away using a single statement is not possible, as long
has certain restrictions.
You can either Create a temporary table or use PL/SQL code to solve your problem:
Temporary Table:
CREATE TABLE TABLE2 AS SELECT TO_LOB(COLUMN1) COLUMN FROM TABLE1;
PL/SQL Code:
DECLARE
VAR1 LONG;
VAR2 VARCHAR2(4000);
BEGIN
SELECT TEXT INTO VAR1 FROM USER_VIEWS WHERE ROWNUM = 1;
VAR2 := SUBSTR(VAR1, 1, 4000);
DBMS_OUTPUT.PUT_LINE(VAR2);
END;