Command outputs
- On the NPS system
or UNIX clients, to save the resulting count value into a variable
for later use, enter:
VAR1=`nzsql -A -t -c "SELECT COUNT(*) FROM test_table"`
- To pipe the output to a printer, enter:
nzsql | lpr
- To send the output to a file (command-line argument), enter:
nzsql -o foo.out
- To send the output to a file (nzsql option),
enter:
nzsql \o foo.out
The nzsql command pipes interactive output (to a screen) through the more command so it can be paginated and scrolled for viewing. To change to another command, set the PAGER environment variable. For example, export PAGER=cat.
If you use the output redirection >
operator to
redirect nzsql command output to a file, as in
the example nzsql -c "select * from myTab;" > /tmp/qry.out
,
note that the order of output in the file is different for Linux or
Windows environments. On a Linux system, the output file has the SQL
command first, followed by the query output. On a Windows client system,
the output file contains the SQL output first, followed by the SQL
command.