Replacing placeholders with variables on revdb_execute

diskot123 at juno.com diskot123 at juno.com
Wed Mar 20 16:54:01 EST 2002


>put revdb_execute(idconnessione,q,a,b) into risultato

You need to pass  variable names (revdb gets the values) for the
placeholders. Changing it to 

put revdb_execute(idconnessione,q,"a","b") into risultato

will get it working.

You could also do something like


put "aa" into myparams[1]
put "bb" into myparams[2]
put "insert into pwd values(:1,:2)" into q
put revdb_execute(idconnessione,q,"myparams") into risultato
and it will get the corresponding values from the array.

------------------
While I have the chance let me give you guys a heads up on some new revdb
features that didn't quite make it into the docs for the 1.1.1RC:

RevDB_Connect
The revdb_connect function connects to a MYSQL, Oracle, ODBC, or
Valentina database.

revdb_connect(databaseType,host,databasename,username,password,[valentina
cachesize],[valentinamacserial],[valentinawinserial])

valentinacachesize -  Makes Valentina create the database cache. By
default it is
3 Mb. The greater the size of your database, the larger the cache should
be - assuming there
is enough RAM. Set on first valentina connect, ignored on subsequent
valentina connection. 

valentinamacserial- Mac serial number for VXCMD to remove the demo
limitations. Set on first valentina connect, ignored on subsequent
valentina connection. 

valentinawinserial - Windows serial number for VXCMD to remove the demo
limitations. Set on first valentina connect, ignored on subsequent
valentina connection.

When connecting to a valentina database the host should be empty and the
databasename should be the filepath of the local database.

For example 

put
revdb_connect("valentina","","c:\todo\todo.vdb","","","","",mywinserial)

For Mac you need to pass a mac styled path as database (param 3) . You
can use the revMacfromUnixPath function.

Some info on Valentina
www.paradigmasoft.com

Valentina is a single user database, which is extremely fast, and works
cross platform (windows, mac classic, carbon). It should be used for
example when you need to distribute a database with your standalone
application.

Users must license VXCMD (which in effect licenses the valentina engine
from paradigmasoft), or else after 10 minutes the valentina database will
time out. 

The advantage to using RevDB over using just VXCMD are

1) You can use the revdb syntax which works for all databases, and
execute all common statements (insert, create table, update, delete,
ect).

2) Passing and retrieving binary data is supported

3) Binding (insert into emp(recid) values(:1)) is fully supported

Some other new revdb functions:

revdb_columntypes
get revdb_columntypes(<cursorid>)
returns the field datatypes in the cursor result set in a database

use the revdb_columntypes to find the datatype of a field.

each item in revdb_columntypes is one of the following:

	"BIT", 
	"CHAR",
	"STRING",
	"WSTRING",  
	"BLOB",
	"TIMESTAMP",
	"DATE",
	"TIME",
	"DATETIME",
	"FLOAT",
	"DOUBLE",
	"INTEGER",
	"SMALLINT",
	"WORD",
	"BOOLEAN",
	"LONG"

revdb_columnisnull
get revdb_columnisnull(cursorid,columnnumber)

return whether (true or false) a column is null(not set at all) as
opposed to empty(set to "").

revdb_querylist
put
revdb_querylist(columndelimiter,rowdelimiter,connectionid,sqlstatement,[v
alues list])

a conveniance to developers, resolves the query, and returns a list of
found records, and closes the cursor. Saves developer from using
revdb_query and then looping over found records using revdb_movenext and
then closing cursor.

Very useful for quickly outputting the results of sql statements to
tables.

if the columndelimiter, rowdelimiter are left empty they default to tab
(for columns) and return for rows.

for example 

put 100 into dontshowthisemployee
put revdb_querylist(,,connectionid, "select FirstName, LastName from
Person
where employeeid <> :1 order by FirstName",  "dontshowthisemployee")

would return:

"Andy<tab>Fuchs<return>
Bill<tab>Mounce<return>
Ed<tab>Leaf"

--
Tuviah Snyder	tuviah at runrev.com
http://www.runrev.com/
Runtime Revolution Limited - Power to the Developer!




More information about the use-livecode mailing list