home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: Java
/
Java.zip
/
rdb084r2.zip
/
dbtest2.nrx
< prev
next >
Wrap
Text File
|
1996-11-07
|
4KB
|
121 lines
/*
A simple netrexx program to test RXDbase.
This time we will read infos directly from the .def
file.
PLEASE: run this example _after_ running dbtest!
*/
options binary
import RXDbase
/* Here the variables declaration */
dbMine = RXDbase() /* instance which will handle the db */
rRec = Rexx[,] /* Here we will store DB infos */
rRec2 = Rexx[2] /* Used to handle (un)delete - we will delete only 1 item */
rArr = Rexx[3,3] /* Used to store data to be written in the archive */
rArr2 = Rexx[,] /* Used to retrieve data from the archive (could have done
it with rArr as well, but did this way for clarity) */
rFileName = Rexx null /* The DB name */
iCount = int 0 /* counters used in the program */
iCount2 = int 0
/* Here the body of the example */
/* First of all, let's connect to the database */
rFileName = 'db' /* Name of the db - I got imagination, heh? */
say 'After the connection the DB is: 'dbMine.connect(rFileName)
rRec = dbMine.getdbinfo() /* We just got the DB record structure */
/* Now, let's write a couple of records */
rArr[0,0] = 2 /* Number of records to be saved on disk */
rArr[1,1] = 'Max' /* First field of the first record. */
rArr[2,1] = 'Marsiglietti' /* Second field of the first record. */
rArr[1,2] = 'Mike' /* First field of the second record. */
rArr[2,2] = 'Cowlishaw' /* Second field of the second record. */
say 'The write operation reported: 'dbMine.saverec(rArr, "OVERWRITE")
/* Retrieve those records and display them on screen */
rArr2 = dbMine.loadrec("Name", "all", "1", 1)
/*
The former line uses "name" as the index.
Also, "1" means 1st record in the specified index.
*/
say rArr2[0,0] || ' records were loaded.'
loop iCount = 1 to rArr2[0,0]
if rArr2[3, iCount] \='N' then /* If it's 'N' then it's deleted */
loop iCount2 = 1 to rRec[0,0]
say 'Record ' iCount', field 'rRec[iCount2,1]': 'rArr2[iCount2, iCount]
end
end
say 'Now deleting Mike!! (haha)'
rRec2[0]=1 /* How many rec to delete/undelete? */
rRec2[1]=2 /* Which one to delete/undelete? */
say dbMine.delerec(rRec2, 1) /* 1 = Delete it */
/* Retrieve those records and display them on screen */
rArr2 = dbMine.loadrec("Name", "all", "1", 1)
/*
The former line uses "name" as the index.
Also, "1" means 1st record in the specified index.
*/
say rArr2[0,0] || ' records were loaded.'
loop iCount = 1 to rArr2[0,0]
if rArr2[3, iCount] \='N' then
loop iCount2 = 1 to rRec[0,0]
say 'Record ' iCount', field 'rRec[iCount2,1]': 'rArr2[iCount2, iCount]
end
end
say 'Now un-deleting Mike, and changing Max to Massimiliano:'
rRec2[0]=1 /* How many rec to delete/undelete? */
rRec2[1]=2 /* Which one to delete/undelete? */
say dbMine.delerec(rRec2, 0) /* 0 = Undelete it */
rArr[0,0] = 1 /* Number of records to be modified */
rArr[0,1] = 1 /* Where has this record to be put? */
rArr[1,1] = 'Massimiliano' /* First field of the first record. */
rArr[2,1] = 'Marsiglietti' /* Second field of the first record. */
say dbMine.modirec(rArr)
/* Retrieve those records and display them on screen */
rArr2 = dbMine.loadrec("Name", "all", "1", 1)
/*
The former line uses "name" as the index.
Also, "1" means 1st record in the specified index.
*/
say rArr2[0,0] || ' records were loaded.'
loop iCount = 1 to rArr2[0,0]
if rArr2[3, iCount] \='N' then
loop iCount2 = 1 to rRec[0,0]
say 'Record ' iCount', field 'rRec[iCount2,1]': 'rArr2[iCount2, iCount]
end
end
/* We just got enough */
say 'Disconnection returned: 'dbMine.disconnect()