home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sqlcla.zip / TT.SPP < prev   
Text File  |  1993-07-15  |  2KB  |  69 lines

  1. // $Header: d:/sh/RCS/tt.spp 1.2 93/07/11 09:48:54 Steve Exp $
  2. #include <sql.hpp>
  3. #include <string.h>
  4. class Assoc
  5.   {
  6.   public:
  7.    short assoc_id;
  8.    char d_last_trans[12];
  9.    char name[41];
  10.    char primary_relation;
  11.    short  d_last_trans_ni;
  12.    short  primary_relation_ni;
  13.   };
  14.  
  15.  
  16. static Assoc ass;
  17.  
  18. Assoc *arr;
  19. char ddd[10]="%BEH%";
  20.  
  21.  
  22. void main(  )
  23.   {
  24.    static long numhits=0;
  25.    static    DATABASE db( "shop", 'S', &sqlca );
  26.    static    SQLCA *sq=&sqlca;
  27.    char eee[20];
  28.    strcpy(eee,"%ART%");
  29.  
  30.    QUERY count( select count(*) into QV( long :numhits )
  31.         from assoc where translate( name ) like QV( char :ddd[10] )
  32.         or translate( name ) like QV( char :eee[10] ) );
  33.  
  34.  
  35.    long rc=count.exec();
  36.  
  37.    CURSOR get( select
  38.      CV( ASSOC_ID , short :ass.assoc_id ),
  39.      CV( D_LAST_TRANS , char :ass.d_last_trans[12] :ass.d_last_trans_ni ),
  40.      CV( NAME , char :ass.name[41] ),
  41.      CV( PRIMARY_RELATION , char :ass.primary_relation :ass.primary_relation_ni  )
  42.      from assoc where translate( name ) like QV(char :ddd[10]) );
  43.  
  44.  
  45. // the following statement avoids calling Assoc constructor numhits times
  46.    arr=(Assoc *) new char[numhits*sizeof( Assoc )];
  47. SQLVAR *t;
  48.  
  49. t=get.outvars();
  50.  
  51. t=get.invars();
  52. for( int j=0; j<4; j++ )
  53.   t++;
  54.  
  55.    get.open();
  56.    rc=sq->sqlcode;
  57.    for( int i=0; i<numhits; i++  )
  58.      {
  59.       get.fetch();
  60.    rc=sq->sqlcode;
  61.       rc=SQLCODE;
  62.       arr[i]=ass;
  63.      }
  64.    get.close();
  65.    rc=sq->sqlcode;
  66.    rc=SQLCODE;
  67.   }
  68.  
  69.