I have SQL queries with bteq that sometimes return no data and it's normal. I want that the export file, even when the query returns no data, contains the columns names. How can I do that please?
Example of one of my queries:
tva()
{
if [ -f "${lien}/test.txt" ]; then
rm -f "${lien}/test.txt"
fi
touch "${lien}/test.txt"
bteq <<EOF >>"${lien}/TVA-${DATE}-log.txt" 2>&1
.logmech LDAP
.LOGON ${TDPID}/${USERID},${PASSWORD}
.set width 2000
.set titledashes off;
.SET FORMAT OFF;
.set session charset 'UTF8'
.export REPORT file="${lien}/test.txt"
SELECT top 5 * FROM ${DB}.TABLENAME
.EXPORT RESET
.set recordmode off
.logoff;
.quit;
EOF
}
tva
I tried to change the recordmode to on, add format off etc but I didn't find any parameter that permits me to displays column name when in the export file when the query returns no data.
Thank you in advance.