Getting started with Rev Databases

Frank D. Engel, Jr. fde101 at fjrhome.net
Sat May 14 08:54:29 EDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think the revdb_ things are leftovers from an older version of the 
RevDB library, with the newer synonyms like revCloseCursor and 
revOpenDatabase being the newer "replacements."  Could be wrong, but 
that was my understanding.

A "cursor" in the sense used by the revCloseCursor command refers to a 
pointer of sorts, but it is not the mouse pointer.  When you query a 
database to retrieve results, you get what is sometimes referred to as 
a "result set."  The "cursor" being referred to by revCloseCursor is a 
pointer into the result set, indicating where your code is currently 
looking within the results.

In short, to use a database, you:

1. Connect to the database -- revOpenDatabase function

2. Query the database -- revQueryDatabase function, revExecuteSQL 
command

3. Retrieve data from the result set (when SELECTing) -- 
revDatabaseColumnNamed function, revDatabaseColumnNumbered function, 
revNumberOfRecords function, revMoveToNextRecord command

4. Close the cursor when finished retrieving information -- 
revCloseCursor command

5. Close the database connection when finished with it -- 
revCloseDatabase command



Real quick, untested example:



put revOpenDatabase("postgresql", "localhost", "myDatabase", 
"myUsername", "myPassword") into dbconn

put revQueryDatabase(dbconn, "SELECT name, phoneNumber FROM myTable") 
into q

put empty into res
repeat for revNumberOfRecords(q) times
   put revDatabaseColumnNamed(q, "name") & tab & 
revDatabaseColumnNumbered(q, 2) & cr after res
   revMoveToNextRecord q
end repeat

revCloseCursor q
put char 1 to -1 of res into field "Results"

revCloseDatabase dbconn



On May 14, 2005, at 2:17 AM, Richard Gaskin wrote:

> Mark Wieder wrote:
>> Richard-
>> Friday, May 13, 2005, 6:44:09 PM, you wrote:
>> RG> Also, what's the difference between commands that start with 
>> "revdb_"
>> RG> and those starting with "revDatabase"?
>> According to the documentation they're synonyms.
>
> Thanks.
>
> That's curious.  Why would they do that?
>
> And some seem to be exceptions, like revdb_closecursor being a 
> function while  revCloseCursor is a command (and the latter doesn't 
> include "database", which might allow it to be confused with something 
> related to the pointer).
>
> Hmmmm....
>
> --
>  Richard Gaskin
>  Fourth World Media Corporation
>  __________________________________________________
>  Rev tools and more: http://www.fourthworld.com/rev
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
- -----------------------------------------------------------
Frank D. Engel, Jr.  <fde101 at fjrhome.net>

$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten 
Son, that whosoever believeth in him should not perish, but have 
everlasting life.
$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFChfUF7aqtWrR9cZoRAgTOAJ40AGFFWyYerX+EdWBT1EvixLZwGQCcCP9u
4QGw6cKJRcogE8ydZvVQIfg=
=h6c8
-----END PGP SIGNATURE-----



___________________________________________________________
$0 Web Hosting with up to 200MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com



More information about the use-livecode mailing list