Occasional heading output with dbaccess
Posted in 2004
I have a file, "tab_file", containing a list of table names. This list
contains only tables which actually have a column named "parm". For each
table in tab_file, I want to display the name of the table and all rows with
parm=1234.
The script below works:
for i in `cat tab_file`
do
echo $i
dbaccess otrk << EOT!! 2>/dev/null
SELECT *
FROM $i
WHERE parm = 1234EOT!!
done
However, sometimes (unnecessary) header information is displayed. Many of
the tables listed in "tab_file" do not have any rows with parm=1234. Most
of the time, when a table fails to have a row with parm=1234, nothing is
displayed except the table name and a blank line. However, sometimes, in
addition to the table name, the column headers are also displayed. Of
course, there is no row data to display when there are no rows with
parm-1234, so I still get the blank line. But (for those tables with no
qualifying rows), occasionally, the headers are also displayed (I'd estimate
less than 10% of the time), while most of the time the headers are not
displayed.
Of course, I can remove the headers completely by adding the line "without
headings" to the script, but I do want the headingss when there are
qualifying rows.
The thing that has me scratching my head (getting even more bald) is, for
tables with 0 qualifying rows, why are the headers displayed sometimes, but
not other times? I'd expect that the headers would either always be there,
or never be there.
Comments welcome.
Thank you.
--
David Grove
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"I think not," said Descartes, and disappeared.