Re: need help with isql and informix
Posted in 1996
What you need to do is load the file in to a temporary table, and then run
the appropriate insert and update queries using the temporary table.
e.g.:
======
create temp table new_data (key_col char(10), data_col char(40));
load from "file.unl" insert into new_data;
update real_data
set data_col = (select data_col
from new_data
where new_data.key_col = real_data.key_col)
where key_col in (select key_col from new_data);
delete from new_data
where key_col in (select key_col from real_data);
insert into real_data select * from new_data;======
The SQL gets a bit more complex if you have a composite key, but you get
the idea. You will probably also want to run the entire thing as a single
transaction. (i.e. Enclose within an "begin work" ... "commit work".)
BTW, who IS the ISP who gives you an Informix engine to work with?
--
Irwin Goldstein
Objective Software Systems, Inc.
http://www.objectsoft.com
areeves@goodnet.com wrote in article <59bt3e$elu@cssun.mathcs.emory.edu>...
> This won't work.. because some records are updates and already
> exsit..
>
> } From: Bill Ennis <ennis@ssax.com>
> } Subject: Re: need help with isql and informix
> } To: tony@toners.com
> } Date: Thu, 19 Dec 96 8:38:05 CST
> } Cc: informix-list@rmy.emory.edu
>
> } Hi,
> }
> } In isql:
> }
> } Select Query Lang.
> }
> } load from "filename" insert into <table name>
> }
> } The pipe is the default delimiter, you could override if you had
> } a a different delimiter (such as a comma).
> }
> } Your isp provides an Infomrix engine for you to use? That's
> } a nice benefit - who are they?
> }
> } -BE
> } >
> } >
> } > I'm using a informix database to store some product data on a isp's
> } > server.. I am getting very little help from their support team..
> } >
> } > can someone help with this problem..
> } >
> } > I need to update records that have changed since I loaded the
> } > database. I have a flat file that contains about 10 records that are
> } > delimited by a pipe '|' and I want to use it to either update or add
> } > the record if the record is not there. I have looked through the
> } > manuals I have on informix and tryed a few things with isql, none
have
> } > worked.. it appears that update command does not have a syntax to
read
> } > a file and that load does not do a modify of a record..
> } >
> } > In other sql's I have used a load would either update an exsiting
> } > record or add if its not there..
> } >
> } > How can I take my 10 records - using isql, and issue a load or update
> } > and have them inserted into the database?
> } >
> } > I have access to isql, perl and csh..
> } >
> } > ---
> } > Tony Reeves
> } > AB6GA - areeves@goodnet.com, tony@toners.com - HF: 14.242Mhz or
28.480Mhz
> } > Environmental Laser - Quality Laser/Copier Toner Cartridge
re-manufacture
> } > Homepage: http://www.toners.com
> } >
> } >
> } >
> }
> }
> } --
> } Bill Ennis Voice: 312-474-7516
> } SSA Fax: 312-474-7460
> } 500 W. Madison email: ennis@ssax.com
> }
> }
>