I have a situation where I have a list of airplanes that make a series of flights.
Therefore I am looking up the different flights that each airplane makes based on a postgres sql query:
select flightid from plane where airplane='DELTAx'
As a result I get a series of flight numbers from this query.
Flight
------
123
567
8976
245
230
140
I currently have a script that puts these flights into an array:
Unix_Array=($(psql -h $PSQL_HOST $PSQL_RDB $PSQL_USER << EOFF
BEGIN TRANSACTION;
select flightid from plane where airplane='Deltax';
END TRANSACTION;
\q
EOFF
))
#echo ${Unix_Array[3]}
#echo ${Unix_Array[4]}
#echo ${Unix_Array[5]}
#echo ${Unix_Array[6]}
which gives an output of:
123
567
8976
Therefore Unix_Array[3]=123
Unix_Array[4]=567 and so on.
Now the second part of the script takes the flight numbers (Unix_Array[]) from the first script and should be getting a flight status from another data base called FlightReport
while [ $counter -lt $count ]
do
echo $counter
echo "flightid = ${Unix_Array[$counter]}"
Flight_Array=($(psql -h $PSQL_HOST $PSQL_RDB $PSQL_USER << EOFF
BEGIN TRANSACTION;
select status from FlightReport where flightid=${Unix_Array[$counter]};
END TRANSACTION;
\q
EOFF
))
counter=`expr $counter + 1`
done
echo "Status is ${Flight_Array[3]}"
The echo status should give me the output of the query
select status from FlightReport where flightid=123, since the value of Unix_Array[3]=123.
I am not getting any value here. Any ideas on what is going on here?
I want to be able to get flight status from FlightReport based on all the flightids that I have obtained from the plane data base. The flightids in plane and Flightreport are the same.
If anyone could help me with this that would greatly be appreciated.
Thanks,
Jason