home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / csso0301.zip / SAMPLES / DAX / TOYS.CSS < prev    next >
Cascading Style Sheet File  |  2000-02-09  |  2KB  |  85 lines

  1. /*  Copyright (c) 1998-2000 IBK-Landquart-Switzerland. All rights reserved.
  2.  *
  3.  *  Module      :  Toys.css
  4.  *  Application :  Sample showing several dax functions in context
  5.  *  Author      :  Peter Koch, IBK
  6.  *
  7.  *  Date        Description                                 Who
  8.  *  --------------------------------------------------------------------------
  9.  *  Feb 1998    First release                               P.Koch, IBK
  10.  *  Feb 1998    Modified for V0.12                          P.Koch, IBK
  11.  *  Feb 2000    Modifications for V2.00                     P.Koch, IBK
  12.  */
  13. #loadLibrary 'KcSysLib'
  14. #loadLibrary 'KcStrLib'
  15. #loadLibrary 'KcDaxLib'
  16.  
  17. main()
  18. {
  19.   // check arguments
  20.   if (sizeof(mainArgVals) < 3) {
  21.     const exc[3] = {
  22.       'usage  : CSS TOYS name/password@connection',
  23.       ' ',
  24.       'example: CSS TOYS SCOTT/TIGER@SALES'
  25.     };
  26.     throw exc;
  27.   }
  28.  
  29.   sysLog('connect');
  30.   var name, pass, conn, a = 2;
  31.   name = strSplitConnectString(mainArgVals[a],pass,conn);
  32.   var link = daxConnect('db2',conn,name,pass);
  33.  
  34.   try {
  35.     sysLog('drop old table');
  36.     daxSimple(link, "drop table csstest");
  37.     daxCommit(link);
  38.   }
  39.   catch (var exc[]) {
  40.     sysLog('no old table to drop');
  41.   }
  42.  
  43.   daxSimple(link,
  44.     "create table csstest ( "
  45.        "ident integer, "
  46.        "descr varchar(30) "
  47.     ")"
  48.   );
  49.  
  50.   sysLog('insert rows');
  51.   var toys = {
  52.     1, 'barbie',
  53.    12, 'football',
  54.   325, 'tomb raider II',
  55.    18, 'flipper'
  56.   };
  57.   var csr = daxParse(link,
  58.               "insert into csstest(ident,descr) "
  59.               "values (#, #30)"
  60.             );
  61.   daxSupply(csr,toys);
  62.   daxDone(csr);
  63.   daxDispose(csr);
  64.   daxCommit(link);
  65.  
  66.   sysLog(
  67.     '# of rows in csstest is '+
  68.     daxSimple(link, "select count(*) from csstest")
  69.   );
  70.  
  71.   sysLog('query rows');
  72.   csr = daxParse(link,
  73.     "select ident, descr from csstest "
  74.      "where ident between #6 and #6 "
  75.      "order by ident"
  76.   );
  77.   var vals = { 10, 1000 };
  78.   daxSupply(csr, vals);
  79.   while (daxFetch(csr, vals))
  80.     sysLog(vals[0]+' - '+vals[1]);
  81.  
  82.   sysLog('disconnect');
  83.   daxDisconnect(link);
  84. }
  85.