Re: Database utility
Posted in 1991
>
>I have two ascii files that contains two diffrent set of data with one common
>key. How would I load into database? I used the DBLOAD command to load the firs
>t ascii file but how would I load the second set of ascii file to merge with
>existing data.
>
I assume that you want all the data in one table rather than keeping the
data in two tables. To do this I would recommend creating the table you
want to populate with the data, and two temporary tables that correspond
to the ascii files you have. You can then select the revelant columns out
of the two temporary tables, and store the results in your real table.
This can be accomplished with an SQL script along the lines of:
create temp table tt1 (
keyfield char(10),
ascf1field1 char(10),
ascf1field2 char(10),
ascf1field3 char(10),
ascf1field4 char(10)
);
create temp table tt2 (
keyfield char(10),
ascf2field1 char(10),
ascf2field2 char(10),
ascf2field3 char(10)
);
create table realtable (
keyfield char(10),
field1 char(10),
field2 char(10),
field3 char(10),
field4 char(10),
field5 char(10),
field6 char(10)
);
load from "asciifile1"
insert into tt1;
load from "asciifile2"
insert into tt2;
insert into realtable
select tt1.keyfield, ascf1field1, ascf1field2, ascf2field1,
ascf2field2, ascf1field3, ascf1field4
from tt1, tt2
where tt1.keyfield = tt2.keyfield;
Hope this helps,
jeffl
----
Jeffrey F. Lawhorn Information Systems Group
Programming Manager Unix, C, and Database Consulting
jfl0@isg.com 450 B Street 16th Floor
sdsu!isg100!jfl0 San Diego, CA 92101 (619) 234-3405 x274