Collect statistics using variable

Database

Collect statistics using variable

Hi,

I was trying to Collect statistics on teradata tables using a variable. All my tables are recorded in a text file from where the script reads and updates the variable reading each line. But its throwing the following error

****Failure 3707 Syntax error expected something like a name between keyword 'ON' and :

Here is the Script:

Bteq << EOF

.logon $env/$user,$pwd,;

database $tdbase;

import vartext file='$scriptdir/tablelist'

using Strtable (varchar(40))

COLLECT STATISTICS ON :Strtable;

.quit 0

EOF

Can somebody help me if variable cant be used in Collect statistics, and any other workaround possible to do the same?

Best Regards

Aaryabhatta
3 REPLIES

Re: Collect statistics using variable

Can somebody advise on the above problem please?

Regards,
Aaryabhatta
Enthusiast

Re: Collect statistics using variable

you can't refer to attribute or object names using a variable.

try this instead.

(
echo "
.logon $env/$user,$pwd;
database $tdbase;
"
cat $scriptdir/tablelist | sed -e 's/^/COLLECT STATISTICS ON /'

echo ".quit 0;"
) | bteq

Re: Collect statistics using variable

Thanks Joe for the clarification, that solved the problem. :)