Hi
I'm trying run a netezza select query from a korn shell script, i'm getting the
data in the below format, is there any way to get only the data in a vairable,
Column_name
--------------------
2014:08:01 12:51:00
i just want the last line which is "2014:08:01 12:51:00"
the command i'm using inside the script is
nzodbcsql -h <hostname> -d <db name> -u <userid> -pw <pwd> -q "select MAX(startdate) from tablename";
i need to get the date in a vairable,
can someone please help me
thanks
MJ
You're going to want to do you queries eliminating column headings. Supposedly -t does this. See reference: http://www-01.ibm.com/support/knowledgecenter/SSULQD\_7.1.0/com.ibm.nz.dbu.doc/c\_dbuser\_nzsql\_commandline_options.html?lang=en
Once you do that assigining the result is something like...
var=`
nzodbcsql -h <hostname> -d <db name> -u <userid> -pw <pwd> -q "select MAX(startdate) from tablename";'
or
var=$(nzodbcsql -h <hostname> -d <db name> -u <userid> -pw <pwd> -q "select MAX(startdate) from tablename";)
You could also do append a tail -1, like...
var=$(nzodbcsql -h <hostname> -d <db name> -u <userid> -pw <pwd> -q "select MAX(startdate) from tablename"; | tail -1)