Re: How do I replace variables in sql with data from file ?????
Posted in 1994
->From: weller@zorro.cecer.army.mil (Bonnie Weller)
->Subject: How do I replace variables in sql with data from file ?????
->Date: 23 Jun 1994 19:43:44 GMT
->Organization: US Army Corps of Engineers - CERL
->
->Hello Informix users/programmers,
->
->I need some programming advice. I am using a SUN OS 4.1.3
->I have Informix SE 5.01, SQL 4.11
->I am unsure how to read information from a data file into a sql file
->containing variables.
->
->What I want to do is read in fields 1, 2 and 4 from "tempa" file into the
->"scripts.sql file", replacing variables
... some details omitted for brevity ...
->
->So question is, how do I get the information from the tempa file to be inputted
->into the species.sql file. (EXAMPLE files below)
->
... more stuff omitted ...
->
->Thanks in advance
->
->weller@zorro.cecer.army.mil
->
->Bonnie
...still more stuff omitted ...
Hello, Bonnie,
There is no way I know of to get file values DIRECTLY into variables in a
script, but there is an easy work-around. Thus my suggestions are:
1. Define a table, I'll call it "temp_dat", to hold your tempa file data.
I'll assume you use easting, northing, and radius for the relevant
columns, and appropriate names for the others.
2. Load it using:
LOAD FROM tempa
INSERT INTO temp_dat;
3. Recast your select as:
SELECT *
FROM sites s, temp_dat t
WHERE
( ( ( s.easting - t.easting ) * ( s.easting - t.easting ) +
( s.northing - t.northing ) * ( s.northing - t.northing )
) < ( t.radius ) * ( t.radius )
)
AND s.easting > 0 AND t.northing > 0
The "s" and "t" are called aliases, in case you hadn't seen 'em before.
Boy, I haven't thought in UTM for a long time. Thanks for the flashback.
Give my regards to Maggie.
Alan ___________________________
______________________| R. Alan Popiel |__________________________
\\ Internet: | Martin Marietta, SLS | /
\\ alan@den.mmc.com | P.O. Box 179, M/S 3810 | Std disclaimers apply. /
)Voice: | Denver, CO 80201-0179 USA | (
/ 303-977-9998 |___________________________| (But you knew that!) \\
/________________________) (____________________________\\