Using a database cursor

Tuviah Snyder tuviah at runrev.com
Thu Sep 5 14:08:01 CDT 2002


>  put "SELECT * FROM tblName WHERE tblName.Login = '" & field "login" & "'"
>into  strSql
>  get revdb_query(field "dbID",strSql)
>  put "Welcome " & revdb_columnbyname(it,"fname") into field "MyMessage"
>  
>  if revdb_recordcount(it) <= 0 then
>    put "Sorry, no login for " & field "login" & " in the database"
>  else
>    put "Welcome " & revdb_columnbyname(it,"fname") into field "MyMessage"
>  end if
>
revdb_recordcount returns -1 for some databases (particularly MS Access), this is a bug in the database itself. A workaround is to fetch all the rows in the resultset until eof. RevDB does not do this because it could be very expensive for huge resultsets.

repeat while revdb_iseof(tcursor) is true
    add 1 to recordcount
end repeat

Below find a modified script

put "SELECT * FROM tblName WHERE tblName.Login = '" & field "login" & "'" into  strSql
get revdb_query(field "dbID",strSql)
put "Welcome " & revdb_columnbyname(it,"fname") into field "MyMessage"
if revdb_iseof(it) is true then
put "Sorry, no login for " & field "login" & " in the database" #first record is eof..resultset is empty 
 else
  put "Welcome " & revdb_columnbyname(it,"fname") into field "MyMessage"
 end if

Tuviah Snyder <tuviah at runrev.com> <http://www.runrev.com/>
Runtime Revolution Limited - The Solution for Software Development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20020905/50d37f7d/attachment.html>


More information about the use-livecode mailing list