Re: Headers in the unload-file
Posted in 1999
Topics: Data Types & Schema Design, Migration, Import/Export & Data Conversion
In some of your last articles you wrote
>>Is there any trick to get an additional header line into the file?
>>(with standard sql! no 4ql, shell-programming, awk ...)
>>
>>First-Name;Last-Name;
>>Peter;Winston;
>>Mike;Wiliam;
>>...
>How's about the following
>
> SELECT "First-Name", "Last-Name"
> FROM table1
> UNION
> SELECT fname, lname
> FROM stuff>
>Where table1 is any table which has exactly one row.
It works fine when all colums are type 'char'. If you have mixed types in
the two tables, this error comes up:
308: Corresponding column types must be compatible for each UNION
statement.
It seems to work, when the second table is inserted into the first table.
Here is my test script.
-------
create temp table stuff
(
fname char(30),
lname char(30),
pid int
) with no log;
insert into stuff values('Peter', 'Winston', 21322);
insert into stuff values('Mike', 'Wiliam', 34212);
create temp table header
(
header1 char(30),
header2 char(30),
header3 char(30)
) with no log;
insert into header values ('First-Name', 'Last-Name', 'Pers.-Id');
-- This statement doesn' t work:
-- 308: Corresponding column types must be compatible for each
-- UNION statement.
unload to '/tmp/stuff.txt' delimiter ';'
select header1, header2, header3
from header
union
select fname, lname, pid
from stuff;
-- This construction seems to work :-)
-- Informix does the casting from 'int' to 'char'
insert into header
select *
from stuff;
unload to '/tmp/stuff.txt' delimiter ';'
select *
from header;
--------
The file looks like it should be.
Thanks for your help.
Bye... Klaus =B-)
--
Klaus Nolte | Living on earth may be expensive ...
knolte@asgard.han.de | ... but it includes an anual free trip around the
sun!