Archives of the TeradataForum
Message Posted: Thu, 23 Jan 2003 @ 21:49:24 GMT
Subj: | | Re: Record count |
|
From: | | Ford, Richard W |
I have a .csh script that automates this process for me... if you prefer you could also wrap MVS JCL around the BTEQ commands...
Here is the generic script code that I use - after this is set up all you have to change is the environment variable DBNAME...
#!/bin/csh -f
#
#
setenv PATH
setenv DBNAME
setenv EXECSQL_FILENAME
setenv SQLRESULTS_FILENAME
setenv TPA_ID
setenv USERID
setenv PSWD
if ( -e $PATH$EXECSQL_FILENAME ) /bin/rm $PATH$EXECSQL_FILENAME
if ( -e $PATH$SQLRESULTS_FILENAME ) /bin/rm $PATH$SQLRESULTS_FILENAME
/bin/bteq << LOAD_SCRIPT_LABEL > /dev/null
.logon $TPA_ID/$USERID,$PSWD;
.set quiet on;
.set echoreq off;
.set width 254;
.set titledashes off;
.export file = $PATH$EXECSQL_FILENAME;
SELECT 'SELECT '''||TABLENAME||' = '''||' |'||'| '||'count(*) (TITLE
=
'''')
FROM '||TRIM(databasename)||'.'||TRIM(TABLENAME)||' ;' (title =
'')
FROM DBC.TABLES
WHERE DATABASENAME = '$DBNAME' ORDER BY TABLENAME;
.export reset;
.set echoreq on;
.set quiet off;
.set titledashes on;
.LOGOFF;
.quit;
LOAD_SCRIPT_LABEL
set return_code = $status
echo "Count $DBNAME rows SQL Generation Return Code is: " $return_code;
/bin/bteq << LOAD_SCRIPT_LABEL > /dev/null
.logon $TPA_ID/$USERID,$PSWD;
.set quiet on;
.set echoreq off;
.set width 254;
.set titledashes off;
.export file = $PATH$SQLRESULTS_FILENAME;
.run file = $PATH$EXECSQL_FILENAME;
.export reset;
.set echoreq on;
.set quiet off;
.set titledashes on;
.LOGOFF;
.quit;
LOAD_SCRIPT_LABEL
set return_code = $status
echo "Execute $DBNAME Count rows SQL Return Code is: " $return_code;
Rick Ford
BOEING
|