Sample 1 (Toys)

C Styled Script
Reference Manual

<< Back  End  Next >>
 
 
INDEX
Introduction
Installation
Using The CSS Executive
Language
Directives
System Library
String Library
Regular Expression Lib.
File Library
Database Library
   daxCommit
   daxConnect
   daxDatabase
   daxDisconnect
   daxDispose
   daxDone
   daxFetch
   daxParse
   daxRollback
   daxRowsProcessed
   daxSelectColumnName
   daxSelectColumns
   daxSelectColumnSize
   daxSelectColumnType
   daxSimple
   daxSupply
   Sample 1 (Toys)
   Sample 2 (Portable)
   Sample 3 (Unknown Table)
C API
C++ API
CSS Links
  

This is an example using several dax functions. Take a userid, password and connection that is available on your system.

#loadLibrary 'KcSysLib'
#loadLibrary 'KcStrLib'
#loadLibrary 'KcDaxLib'
 
main()
{
  // check arguments
  if (sizeof(mainArgVals) < 3) {
    const exc[3] = {
      'usage  : CSS TOYS name/password@connection',
      ' ',
      'example: CSS TOYS SCOTT/TIGER@SALES'
    };
    throw exc;
  }
 
  sysLog('connect');
  var name, pass, conn, a = 2;
  name = strSplitConnectString(mainArgVals[a],pass,conn);
  var link = daxConnect('db2',conn,name,pass); // (*)
 
  try {
    sysLog('drop old table');
    daxSimple(link, 'drop table csstest');
    daxCommit(link);
  }
  catch (var exc[]) {
    sysLog('no old table to drop');
  }
 
  daxSimple(link,
    'create table csstest ( '
       'ident integer, '        // (*)
       'descr varchar(30) '
    ')'
  );
 
  sysLog('insert rows');
  var toys = {
    1, 'barbie',
   12, 'football',
  325, 'tomb raider II',
   18, 'flipper'
  };
  var csr = daxParse(link,
              'insert into csstest(ident,descr) '
              'values (#, #30)'
            );
  daxSupply(csr,toys);
  daxDone(csr);
  daxDispose(csr);
  daxCommit(link);
 
  sysLog(
    '# of rows in csstest is '|
    daxSimple(link, 'select count(*) from csstest')
  );
 
  sysLog('query rows');
  csr = daxParse(link,
    'select ident, descr from csstest '
     'where ident between # and # '
     'order by ident'
  );
  var vals = { 10, 1000 };
  daxSupply(csr, vals);
  while (daxFetch(csr, vals))
    sysLog(vals[0]|' - '|vals[1]);
 
  sysLog('disconnect');
  daxDisconnect(link);
}

For ORACLE you would have to change the statements marked (*) to:

  var link = daxConnect('oracle',conn,name,pass);
  ...
  daxSimple(link,
    'create table csstest ( '
       'ident number(6), '
       'descr varchar2(30) '
    ')'
  );

If you want to write database independant dax scripts have a closer look to the Sample 2 (Portable).

 Copyright © IBK LandquartLast revised by Peter Koch, 24.02.00<< Back  Top  Next >>