Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 23 Dec 2008 @ 12:29:20 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: How to Get Count(*) in UNIX Variable
 
From:   Summersgill, James

To add to Quincy Leslie�s post, a way to extract the count from a table is to write the results of a query using the BTEQ ".export" command.

     /*  BTEQ code  snippet */

     .export file=count_table1

     sel count(*) as recs from table1

     .export reset



     .export file=count_table2

     sel count(*) as recs from table2

     .export reset



     # KSH code snippet     "expression_to_get_table`_count that Quincy
     refers to"

     export CT1=`tail -1 count_table1 | awk '{print $1}'`

     export CT2=`tail -1 count_table2 | awk '{print $1}'`

At this point you may perform the unix shell comparisons described in Quincy�s post.

To compare the values then use the shell script comparison techniques, which which will be slightly different depending on whether you are using Korn Shell, Bourne Shell, or C Shell. A variation on Bourne & Korn C

     IF [ $CT1 > $CT2 ]      if [ $CT1 > $CT2 ]         if [ $CT1 > $CT2 ] then

           THEN                         then do_action

               Shell_action             do_action               endif

          FI                                    fi

Jim Summersgill



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023