home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
csso0301.zip
/
SAMPLES
/
DAX
/
PORTABLE.CSS
next >
Wrap
Cascading Style Sheet File
|
2000-02-11
|
3KB
|
102 lines
/* Copyright (c) 1998-2000 IBK-Landquart-Switzerland. All rights reserved.
*
* Module : Portable.css
* Application : Modified toys example running on either database
* 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 PORTABLE db:name/password@connection',
' (db defaults to DB2)',
'example: CSS PORTABLE SCOTT/TIGER@SALES'
};
throw exc;
}
sysLog('connect');
var db, name, pass, conn, a = 2;
name = strSplitConnectString(mainArgVals[a],pass,conn,db);
if (db == '') db = 'DB2';
var link, integer, varchar;
switch (db) {
case 'DB2':
varchar = 'varchar';
integer = 'integer';
break;
case 'ORACLE':
varchar = 'varchar2';
integer = 'number(6)';
break;
default:
throw '%%% unknown db: '|db;
} // switch
link = daxConnect(db, conn, name, pass);
sysLog('running on '|daxDatabase(link));
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);
}