Using a database cursor

sschofield sschofield at computing.dundee.ac.uk
Fri Sep 6 03:44:01 CDT 2002


i shall try this. i must say i'm very impressed at the help i've received so
far on my queries. 
 
Trevor, the reason i've filled the my message outwith the if statement was
just to check the sql was actually finding a record. 
 
I recollect an older version of VB where you had to go to the bof and eof to
get the recordcount to work. But certainly in vb 6 you just use recordcount.
Maybe something for future version of rev?
 
-----Original Message-----
From: Tuviah Snyder [mailto:tuviah at runrev.com] 
Sent: 05 September 2002 18:48
To: use-revolution at lists.runrev.com
Subject: RE: Using a database cursor





>  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 <mailto:tuviah at runrev.com> >
<http://www.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/20020906/e92d4fbf/attachment.html>


More information about the use-livecode mailing list