home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1998-2000 IBK-Landquart-Switzerland. All rights reserved.
- *
- * Module : Toys.css
- * Application : Sample showing several dax functions in context
- * Author : Peter Koch, IBK
- *
- * Date Description Who
- * --------------------------------------------------------------------------
- * Feb 1998 First release P.Koch, IBK
- * Feb 1998 Modified for V0.12 P.Koch, IBK
- * Feb 2000 Modifications for V2.00 P.Koch, IBK
- */
- #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 #6 and #6 "
- "order by ident"
- );
- var vals = { 10, 1000 };
- daxSupply(csr, vals);
- while (daxFetch(csr, vals))
- sysLog(vals[0]+' - '+vals[1]);
-
- sysLog('disconnect');
- daxDisconnect(link);
- }