How do I replace variables in sql with data from file ?????
Posted in 1994
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 with certain fields from the "tempa"
file. Field 1 is to replace variable &easting, field 2 is to replace variable
&northing and field 3 is to replace &radius. (pipe is the delimiter) What
the sql script does is it reads in UTM data from the "tempa" file and finds
all records that fall with a given radius of that point. Ultimately, these
results will be outputted to a report using ACE (I'm not that far yet :-))
So question is, how do I get the information from the tempa file to be inputted
into the species.sql file. (EXAMPLE files below)
Please couch suggestions with comments so that I can follow your logic (and
hopefully learn more programming skills--a real weak point for me-- thus
relying on my own knowledge in the future, instead of relying on the kindness
of strangers.)
Thanks in advance
e-mail prefered.
weller@zorro.cecer.army.mil
Bonnie
___________________________SAMPLE FILES______________________________
My sql script. Called "species.sql"
output to "species.out"
SELECT *
FROM sites
WHERE
( ( ( easting - &easting ) * ( easting - &easting ) +
( northing - &northing ) * ( northing - &northing )
) < ( &radius ) * ( &radius )
)
AND easting > 0 AND northing > 0
*******************
My data file. Called "tempa"
368345|3586176|L-165|5700|376221|3678928|INTRCPT 4|5700
371105|3582762|L-216|5000|375234|3684851|INTRCPT 8|5000
0|0|L-218|5700|375608|3694884|INTRCPT 9|5700
348121|3740748|L-223|5700|363686|3716306|INTRCPT11|5700
371097|3582752|L-275|5700|366734|3734660|INTRCPT 12|5700
383550|3588252|L-317|500|362482|3739235|Mine Site LAUNCH|500
373855|3585843|L-21|5700|377623|3692852||5700
373601|3585849||0|374620|3663015|INTRCPT 2|5700
366579|3594975|L-153|5700|373009|3674109|INTRCPT 3|0
0|0||0|376221|3678928|INTRCPT 4|5700
********************
Database is called spcs_loc
My sites file contains 4 fields
species_num char(9),
easting integer,
northing integer,
radius integer,
data looks like this, before loading.
20100010|377880|3691405|200
20103600|369415|3685637|300
11300011|359940|3619143|1500
20501201|359940|3619143|1500
11500010|374200|3671300|20
11500010|374000|3672400|20
11500010|351040|3757010|20
11500010|350880|3756490|20
11500010|350940|3756500|20
20300257|364865|3578780|30