This example shows how to use the DBTester functions together to access a database. It uses all the DBTester functions except DB_FetchPrev, which you use exactly as you use DB_FetchNext. While the example is based on a sample database, but the technique is the same regardless of which ODBC database you are accessing.
[-] testcase DBTest () appstate none [ ] [ ] // This test uses the functions in DBTester [ ] // to directly access an ODBC database [ ] [ ] [ ] INTEGER id, iheadID [ ] STRING sDeptName [ ] HDATABASE hdbc [ ] HSQL hstmnt [ ] [ ] [ ] // connect to SQL 2000 Server Test DB [ ] hdbc = DB_Connect ("dsn=SQLServer;PWD=sql;UID=dba") [ ] [ ] // retrieve info from Department table [ ] hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM department") [ ] [ ] // process the information that came back [ ] print ("Here's the info in the Department table:") [ ] print () [-] while (DB_FetchNext (hstmnt, id, sDeptName, iheadID)) [ ] print ("Dept: {id} Name: {sDeptName} Head: {iheadID}") [ ] [ ] // release resources (unneeded really [ ] // because immediately followed by disconnect) [ ] DB_FinishSQL (hstmnt) [ ] [ ] // disconnect [ ] DB_Disconnect (hdbc) [ ] [ ] // Results: [ ] // Here's the info in the Department table: [ ] // [ ] // Dept: 100 Name: R & D Head: 501 [ ] // Dept: 200 Name: Sales Head: 902 [ ] // Dept: 300 Name: Finance Head: 1293 [ ] // Dept: 400 Name: Marketing Head: 1576 [ ] // Dept: 500 Name: Shipping Head: 703