another beginning SQL/Rev question

Dave Cragg dcragg at lacscentre.co.uk
Sun Oct 9 16:20:19 EDT 2005


On 9 Oct 2005, at 19:26, Charles Hartman wrote:

> Something I don't understand about the revExecuteSQL command. I  
> open my MySQL database and get an id. Now, to make later steps more  
> general purposes, I'd like to ask the database for the structure of  
> one of its tables (number of columns, column names) rather than  
> hardwiring that into the Rev front-end. So I should be able to  
> create a
>     global myArray
> and then with my dbID in hand,
>     revExecuteSQL dbID, "show columns in myTable", "myArray"
> (taking care to put quotes around myArray as the docs say).
>
> Trouble is, nothing shows up in myArray, or anywhere else as far as  
> I can see. Using a variable (or several) instead of myArray doesn't  
> help, neither does putting some dummy stuff ("") into myArray[1],  
> myArray[2], etc., ahead of time.

The variable or array is used to substitute values in the SQL  
statement, not to receive data from the query.

Try using revdb_querylist (or revDataFromQuery) to execute SQL that  
returns data.

For example

    put "show columns in myTable" into tQuery
    put revdb_querylist(,, dbID,tQuery) into tData
    put tData into field "whatever'

The docs aren't too clear on this. They seem to say use revdb_execute  
(or revExecuteSQL) for everything except SELECT statements. But I  
think we have to infer that any SQL that returns data should be  
treated in the same way as SELECT. (as opposed to INSERT, UPDATE,  
etc. where we should use revdb_execute)


Cheers
Dave



More information about the use-livecode mailing list