Using SQL and revDatabase methods with Valentina

Walton Sumner wsumner at im.wustl.edu
Thu Jan 31 17:50:52 EST 2008


Help, please. I'm using Valentina 2.5.8 (superbundle), and would like to use
SQL or the Revolution methods for the sake of portability, but I have not
learned to do this yet. The Valentina direct access functions work, so most
of the pieces must be in place. What am I doing wrong? Here's an example:

function errorCheck pDialog
    if Valentina_ErrNumber()<>0 then
        if pDialog<>false then
            answer Valentina_ErrString()
        end if
        return "Error"
    end if
    return ""
end errorCheck

--see here for the tQuery prototype:
http://www.valentina-db.com/dokuwiki/doku.php?id=paradigma:public:en:documen
tation:vsql:reference:show:show_table

--This function should list the tables in sDatabase
--sDatabase is a script level variable identifying the database
function DatabaseTables

    local tQuery = "SELECT name FROM (SHOW TABLES) WHERE type = 'TABLE'"
    local tList,tArray,tFirstRec,tMaxRec,tCursor
    put "" into tArray

    breakpoint

    put VDatabase_SqlSelectRecords(sDatabase, \
       tQuery,"kClientSide","kReadOnly","kForwardOnly", \
       tArray,1,-1,tab,CR) into tList
    get errorCheck() --> Unexpected token SHOW

    put "SELECT * FROM (SHOW TABLES)" into tQuery
    put VDatabase_SqlSelectRecords(sDatabase, tQuery,"kClientSide", \
       "kReadOnly","kForwardOnly",tArray,1,-1,tab,CR) \
       into tList
    get errorCheck() --> Unexpected token SHOW

    put VDataBase_SqlSelect( sDatabase, tQuery,"kClientSide", \
       "kReadOnly", "kForwardOnly", tArray ) into tCursor
    get errorCheck() --> Unexpected token SHOW
     
    --local tList
    local tCount, i, tReference, tName, tID, tFields, tRecords
    put VDataBase_TableCount( sDatabase ) into tCount
    repeat with i = 1 to tCount
        put VDatabase_Table( sDatabase, i ) into tReference
        put VTable_Name( tReference ) into tName
        put VTable_ID( tReference ) into tID
        put VTable_FieldCount( tReference ) into tFields
        put VTable_RecordCount( tReference ) into tRecords
        put i & tab & tName & tab & tReference & tab & tID \
            & tab & tFields & tab & tRecords & CR after tList
    end repeat
    delete last char of tList
    return tList --> tList is correct
end DatabaseTables

In general, I find that Valentina examples, tutorials, etc, use the direct
Valentina calls for a wide range of operations, and SQL and revDatabase
methods for far fewer operations, if any.

Before I surrender and use only Valentina calls, are there some working
examples of the other two strategies lying about?

And how do you get "SHOW TABLES" to work in a select statement?

Thanks,

Walt Sumner




More information about the use-livecode mailing list