Using a list to loop through records


cn = sql::Connection

rs = sql::ResultSet

args = sql::Arguments

vsql = "SELECT client_id FROM client"

cn.execute(vsql)

rs = cn.resultset

clst = rs.ToString()


'==update Client with total hours and hourly charges

dim vttl_amt as n

dim vttl_hrs as n

for each foo in clst

       vsql = "SELECT * FROM billing WHERE type_id='HRS'

       cn.execute(vsql)

       rs = cn.ResultSet

       vttl_amt = rs.data("ttl_amt")

       vttl_hrs = rs.data("ttl_hrs")

       vsql = "UPDATE client SET c_cur_hrs_charges={vttl_amt},c_cur_hours={vttl_hrs} WHERE client_id={foo}"

       vsql = evaluate_string(vsql)

       if cn.execute(vsql) = .f.

               lst3 = lst3 + cn.callresult.text + crlf()

       end if

next