Rexx - Read Operation


Advertisements

A READ Operation on any database means to fetch some useful information from the database. Once our database connection is established, you are ready to make a query into this database.

The following example shows how to fetch all the records from the employee table.

Example

/* Main program */ 
Call RxFuncAdd 'SQLLoadFuncs', 'rexxsql', 'SQLLoadFuncs' 
Call SQLLoadFuncs 

if SQLConnect(c1,'testuser','test123','testdb') == 0 then say 'Connect Succedded' 
if SQLCommand(u1,"use testdb") == 0 then say 'Changed database to testdb' 
sqlstr = "select first_name,last_name,age,sex,income from employee" say 
   SQLCommand(c2,sqlstr) 

say c2.first_name.1 
say c2.last_name.1 
say c2.age.1 
say c2.sex.1 
say c2.income.1

The output of the above program would be as shown below.

Connect Succedded 
Changed database to testdb 
0 
Mac 
MOhan 
20 
M 
2000 
rexx_databases.htm
Advertisements