RE: How to LOAD selected columns from a delimited file?
Posted in 1997
It is very simple, you should use the dbload command, it assigns a virtual
name for every field in the ascii file, in your case is data.psv, so you can
refer to those virtual fields which are from f01 , f02, f03 ....etc.
% dbload -d yourdatabase -c command_file
Where command_file can contain the following 2 lines:
file data.psv delimiter "|";
insert into tests(id,product,val1,val3)
values(f01,f02,f03,f05):
Enjoy!
----------------------------------------------------------------
Mario Estrada | SISTECO, S.A.
Departamento | Tel.(502) 3340214
de Soporte de Informix | Fax(502) 3344837
----------------------------------------------------------------
--------------------------------->Reply Separator<-------------------------------------
----------
From: Matt Reprogle[SMTP:mcreprog@mail.delcoelect.com]
Sent: Martes 25 de Marzo de 1997 12:42 PM
To: informix-list@rmy.emory.edu
Subject: How to LOAD selected columns from a delimited file?
I have searched the docs, but cannot find out how use the LOAD command
to insert selected columns from a delimited file. Example:
data.psv (input file)
-----------
ID|PRODUCT|VAL1|VAL2|VAL3
24|XYZ|1.2|3.4|5.6
columns in table "tests":
-------------------------
id
product
val1
val3
I want to do something like (%%bad syntax alert!%%):
load from "data.psv" columns(ID,PRODUCT,VAL1,VAL3) insert into tests
or
load from "data.psv" insert into tests(id,product,val1,NULL,val3)
or
load from "data.psv" insert into tests(id,product,val1,,val3)
The first one is bad syntax, and the last two fail when executed.
Is something like this possible, or do I have to strip the unwanted
columns from the input file first to make it match the table?
TIA,
--
Matt Reprogle
Delco Electronics - IC Integrated Manufacturing phone:(317)451-9651
mcreprog@koicew00.delcoelect.com FAX: (317)451-8230