Using a database cursor

sschofield sschofield at computing.dundee.ac.uk
Thu Sep 5 11:16:01 EDT 2002



-----Original Message-----
From: sschofield [mailto:sschofield at computing.dundee.ac.uk] 
Sent: 05 September 2002 16:38
To: 'use-revolution at lists.runrev.com'
Subject: RE: Using a database cursor


Thanks again. I now have the results coming out of my database, yippee. You
mention the documentation which I have indeed consulted, but I find the
examples rather bald. They're never embedded in code. Eg. I'm now trying to
find the recordcount so I can reject the login if recordcount < 0. but it
doesn't seem to work. The example code is a bald
revdb_recordcount(westCoastCustomers).

  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

Both welcomes Sian (so obviously found a record) and gives message Sorry no
login cos it claims recordcount(it) is -1.


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


I read your first email too quickly and didn't notice you wanted to use
column numbers rather than column names.  So if you wanted to map the
results from a database query to an array in Rev then you could do something
like this:

put 1 into iteration
repeat while revdb_iseof(dbCursor) is false
    put revdb_columnbynumber(dbResult, 1) into dbArray[iteration, "Name"]
    put revdb_columnbynumber(dbResult, 2) into dbArray[iteration, "Login"]
    
    get revdb_movenext(dbResult)
    add 1 to iteration
end repeat

If you go to Help -> Revolution Documentation -> Transcript Language
Dictionary and select "Database" from the Show dropdown menu it shows all
the database related functions which is really helpful.

Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com


>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
>
>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)
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Login.rev
Type: application/octet-stream
Size: 8372 bytes
Desc: not available
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20020905/2a57ee65/attachment.obj>


More information about the Use-livecode mailing list