Using a database cursor

sschofield sschofield at computing.dundee.ac.uk
Thu Sep 5 09:47:01 CDT 2002


ta

-----Original Message-----
From: Trevor DeVore [mailto:trevor at mangomultimedia.com] 
Sent: 05 September 2002 15:39
To: use-revolution at lists.runrev.com
Subject: Re: Using a database cursor


On 9/5/02 sschofield at computing.dundee.ac.uk (sschofield) wrote

>I've openend up a database connection and want to map the data. I've 
>set up my cursor but how do I now use it?
>
>put "SELECT * FROM tblName WHERE tblName.Login = '" & field "login" & 
>"'" into strSql get revdb_query(field "dbID",strSql)
>
>This seems to be fine, but I can only get it to return things like how 
>many records. How do I get eg the first field of the first record in 
>the cursor? I tried

Try:
put revdb_columnbyname(it, "Login")


>
>put item 1 of line 1 of it into field "MyMessage"
>
>But it didn't like that. Also, how do I rename the cursor? I tried
>
>rsLogin = get revdb_query(field "dbID",strSql)

put revdb_query (field "dbID",strSql) into rsLogin

Your cursor will now be called rsLogin.

In addition, if you wanted to put the results returned from the database
into an array as well as check that a record was returned you could do this:

-- Create array
if revdb_iseof(dbCursor) is false then
    put revdb_columnbyname(dbCursor, "YourDbField1") into
dbArray["YourDbField1"]
    put revdb_columnbyname(dbCursor, "YourDbField2") into
dbArray["YourDbField2"]
    put revdb_columnbyname(dbCursor, "YourDbField3") into
dbArray["YourDbField3"] else
    put "No record found"
end if

Hope this helps,

Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com _______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list