home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
sybaserx.zip
/
SYBRX.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1996-01-27
|
5KB
|
158 lines
/*******************************************************************/
/* */
/* SYBRX.CMD */
/* */
/* This program calls the various REXX external functions */
/* provided in the SYBREXX.C function package. */
/* */
/* Each function is called once to illustrate how it is used. */
/* Some of the functions have multiple options and multiple */
/* types of output, but not all options are used here. */
/* */
/*******************************************************************/
'@echo off'
/* Modify these variables to suite your environment */
UserID = 'sa'
Password = 'alicee'
Database = 'Master'
Server = 'DUNX_NB'
/* RxSybLoadFuncs: This function will load all the rest, */
/* so we do not have to make many calls to RxFuncAdd. */
Say 'This program will call many of the REXX functions provided'
Say ' in SYBREXX.DLL. The first one is RxSybLoadFuncs, which makes'
Say ' all the others available.'
Say ' '
call RxFuncAdd 'RxSybLoadFuncs', 'SYBREXX', 'RxSybLoadFuncs'
call RxSybLoadFuncs
/* Set return codes */
SUCCEED = 1
FAIL = 0
NO_MORE_ROWS = -2
MORE_ROWS = -1
TRUE = 1
FALSE = 0
Say RxDbversion()
Say
/*** Demonstrate RxDbsethandlers ***/
Call RxDbsethandlers('no messages') /* Note that this is not implemented */
/* Passing a filename (or any string)*/
/* prevents messages from appearing */
/* on the screen. An empty string */
/* will send messages to the screen */
/*** Demonstrate RxDbsetlogintime ***/
Call RxDbsetlogintime('5')
/*** Demonstrate RxDbsettime ***/
Call RxDbsettime('0')
pLoginRec = RxDblogin() /* Get a Login Structure */
Call RxDbsetluser pLoginRec, UserID /* Set the User ID in the Login Struct */
Call RxDbsetlpwd pLoginRec, Password /* Set the Password in the Login Struct */
Call RxDbsetlhost pLoginRec, 'SYBREXX' /* Set the Host in the Login Struct */
Call RxDbsetlapp pLoginRec, 'SYBRX.CMD'/* Set the Applic in the Login Struct */
Call RxDbsetlencrypt pLoginRec, TRUE /* Set password encryption on */
dbproc = RxDbopen(pLoginRec, Server) /* Open a DBPROCESS */
if (dbproc == 0) then do /* Be sure to check we have a valid */
Say 'dbopen failed!' /* DBPROCESS before continuing! */
exit
end
RetCode = RxDbuse(dbproc, Database) /* Set the Database */
/* Set up a SQL command string */
RetCode = RxDbcmd(dbproc, "select name, crdate from sysdatabases")
if (RxDbsqlexec(dbproc) <> SUCCEED) then do /* Execute it */
Say 'dbsqlexec failed!'
Call RxDbclose(dbproc)
exit
end
if (RxDbresults(dbproc) <> SUCCEED) then do /* Check results */
Say 'dbresults failed!'
Call RxDbclose(dbproc)
exit
end
if (RxDbrows(dbproc) <> SUCCEED) then do /* Check if rows are returned */
Say 'dbresults failed!'
Call RxDbclose(dbproc)
exit
end
/*** Write out the Titles ***/
Say Substr('Name',1,31) substr('Creation Date',1,31)
Say Substr('',1,31,'-') substr('',1,31, '-')
do while (RxDbnextrow(dbproc) == MORE_ROWS)
/*** Get the Data ***/
/* NOTE: At this stage RxDbdata only allocates 256 bytes for the returned */
/* data - I still need to make it smarter so that it will allocate */
/* additional storage if required */
/* This will probably only impact TEXT and BINARY columns */
Name = RxDbdata(dbproc, '1') /* Set Name = results column 1 */
CrDate = RxDbdata(dbproc, '2') /* Set CrDate = results column 2 */
Say Substr(Name,1,31) substr(CrDate,1,31)
end
Call RxDbclose(dbproc) /* Close the DBPROCESS */
Call RxSybDropFuncs
say; say 'SYBRX demonstration program is complete.'
say;
say 'Written by: Duncan A. Groenewald'
say ' 12 Nursery Lane'
say ' CONSTANTIA'
say ' CAPE TOWN'
say ' South Africa'
say
say
say 'Internet: duncang@iaccess.za'
say
exit
SysPause:
parse arg prompt
if prompt='' then
prompt='Press Enter key when ready . . .'
call SysSay prompt
Pull .
say
return
SysSay:
parse arg string
call charout 'STDOUT', string
return