RE: A "Load from" question.
Posted in 1998
You would need to have one (or more) spaces between the delimiters.
UNIX users can alter the input file with a small awk script, such as:
BEGIN { FS = "|"; OFS = "|" } # Define '|' as field separator
#
(($1=="")) {$1=" "}
(($2=="")) {$2=" "}
(($3=="")) {$3=" "}
{print $0}
-----Original Message-----
From: Suhas Tembe [mailto:stembe@arrowshirt.com]
Sent: Monday, September 28, 1998 15:45
To: informix-list@iiug.org
Subject: A "Load from" question.
Hi Guys,
Let me tell you what exactly I am looking for :
I have a temp table "temp_table" with say 3 columns as ;
col1 char(2);
col2 char(2);
col3 char(2);
I also have a delimited (|) flat file with 3 columns & I have to load
data from the flat file into this "temp_table".
The flat file looks like this :
ab||cd --- line 1
|ab|cd --- line 2
ab|cd|| --- line 3
I load data into the "temp_table" as follows :
load from "flat_file.txt"
insert into temp_table;
Now, when I do this, row # 1 in the table would like :
col1 = ab
col2 = null
col3 = cd
Similarly, row # 2 & row # 3 as :
col1 = null
col2 = ab
col3 = cd
col1 = ab
col2 = cd
col3 = null
As you can see, a "null" is inserted into the column(s) if there is no data.
(Note : There is no space between the pipes in the flat file).
My question is, what would I have to do if I wanted "spaces" & not "nulls"
to
be inserted into the table. ( I don't want to give an "update" statement for
every
column in the table).
Any help is appreciated. Thanks in advance.
Suhas
--------------------------------------------------------
Name : Suhas Tembe
E-mail: <stembe@arrowshirt.com>
Date : 09/28/98
Time : 17:45:14
Place : Atlanta, Georgia.
--------------------------------------------------------