Hi Sebastien,
It takes some processing steps, but how about considering using an external table?
Below is what I tested using the stores_demo sample table.
drop table "informix".cat3;
drop table "informix".cat4;
-- step 1. Create external table to download source data (table 'cat2')
create external table "informix".cat3
(
catalog_num serial not null ,
stock_num smallint not null ,
manu_code char(3) not null ,
cat_descr varchar(255),
cat_advert varchar(255,65)
) using (datafiles ('disk:/tmp/cat3.unl'), format 'delimited');
-- step 2. Create target table to upload source data
create table "informix".cat4
(
catalog_num serial not null ,
stock_num smallint not null ,
manu_code char(3) not null ,
cat_descr text, -- varchar->text
cat_advert text -- varchar->text
);
-- step 3. Download source data
insert into cat3 select catalog_num,stock_num,manu_code,cat_descr,cat_advert from cat2;
-- step 4. Changing the external table schema (Downloaded file is not deleted.)
drop table "informix".cat3;
create external table "informix".cat3
(
catalog_num serial not null ,
stock_num smallint not null ,
manu_code char(3) not null ,
cat_descr text,
cat_advert text
) using (datafiles ('disk:/tmp/cat3.unl'), format 'delimited');
-- step 5. Upload data to target table
insert into cat4 select * from cat3;
------------------------------
SangGyu Jeong
Software Engineer
Infrasoft
Seoul Korea, Republic of
------------------------------
Original Message:
Sent: Tue May 12, 2020 04:35 AM
From: SEBASTIEN SF FLAESCH
Subject: ALTER TABLE to change CHAR/VARCHAR/LVARCHAR to TEXT
Hello,
I am looking for a pure SQL (or maybe using some stored procedure code) to change a CHAR / VARCHAR / LVARCHAR column to a TEXT column, with data inside.
I know there is a CLOB type but we want to use TEXT.
It must not use dbaccess (LOAD/UNLOAD): It must be pure SQL or SP that can be called from Java/JDBC or 4GL or any language with Informix client interface, to do basic PREPARE+EXECUTE or EXECUTE IMMEDIATE with a set of pure SQL commands that are defined in a script file.
Any suggestion or workaround is welcome.
Thanks!
Seb
------------------------------
SEBASTIEN SF FLAESCH
------------------------------
#Informix