I have a shell script which will connect to database and get the results. My script is like
#!/bin/bash
getResults()
{
db2 "connect to ${1} user ${2} using ${3}"
db2 "set schema ${4}"
status=`db2 -x "select status from results where id=1"`
echo $status
}
#MAIN STARS HERE
getResults dbname foo bar test
Now I wanted to get multiple columns from results tables using
select status,timestamp from results where id=1
How can I run the above query and capture both status and timestamp into two different shell variables using single query instead of running 2 differnt queries like
#!/bin/bash
getResults()
{
db2 "connect to ${1} user ${2} using ${3}"
db2 "set schema ${4}"
status=`db2 -x "select status from results where id=1"`
echo $status
timestamp=`db2 -x "select timestamp from results where id=1"`
echo $timestamp
}
#MAIN STARS HERE
getResults dbname foo bar test
My results table is like:
create table (id number, status char(1), timestamp datetime);
And data is like
1 P <some ts>
2 F <some ts>
Thanks in advance!