fetch()

Description: fetches and returns a row from a rowset

Syntax: fetch(f)

Parameters:

The return type is a record with fields names equal to the selected table columns (see sql() for column selection)


Code Example
procedure main()
 f:=open("mydb","O","federico","mypassword") # open ODBC connection on DSN mydb

 # select 3 existing columns from table mytable and

 sql(f,"SELECT id,name,amt FROM mytable")

 # *f = number of selected rows
 # may not work with some DBMS

 write(*f," row(s) selected")
 write("\nrow values")

 # fetch returns a record
 # fields name are the columns names selected with dbselect
 # in this example we can reference fields using row["id"],
 # row["name"] and row["amt"]

 while (row:=fetch(f)) do { # while rows to retrieve
   every col:=(1 to *row) do  # for each column (*row = row size)
     writes("[",row[col],"]") # write row field
   write()
 }

 close(f) # close ODBC connection
end