Close all databases - CRASH

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Mon Oct 14 08:23:57 CDT 2013


On 10/14/13 3:27 PM, "Mark Schonewille" <m.schonewille at economy-x-talk.com>
wrote:

> Hi Ruslan,
> 
> This is my script:
> 
> function queryTest
>     // put VDatabase_SqlSelect(lDatabase,"SHOW DATABASES") into myCursor
>     put vDatabase_SqlQuery(lDatabase,"SHOW DATABASES") into myCursor
                        ^^^^^^^^

Wrong.

vDatabase_SqlQuery returns not cursorRef but QueryResultRef !!


>     put VCursor_RecordCount(myCursor) into recNum

You use Apple instead of Tomato
Of course you get problem


>     put VCursor_GetRecords(myCursor,1,recNum,tab,cr) into myData
>     put VCursor_Destructor(myCursor) into myCursor
>     return myData
> end queryTest


 
> lDatabase is a locally defined variable that contains a valid
> databaseID.  VDatabase_SqlSelect() works but vDatabase_SqlQuery()
> doesn't. It crashes at VCursor_GetRecords().

Of course it not works

 
> Please, explain how to use QueryResult in LiveCode. Documentation for
> LiveCode doesn't exist at
> http://www.valentina-db.com/docs/dokuwiki/v5/doku.php?id=valentina:products:ad
> k:api:vqueryresult_class:vqueryresult_class
> This page just says something like "yup, there are properties, but we
> won't tell you what properties are and how to use them".

Look.

Originally, in Valentina DB was only TWO methods:

I write syntax in general OOP way:

    db.SqlSelect()  -- to execute SELECT command,
                    and other commands, which returns you CURSOR.

    db.SqlExecute() -- returns ULONG, usually number of affected rows
            intended for INSERT, DELETE, UPDATE and all other commands.
            

Later we have meet commands, which need more than these two commands could
offer.  Also sometimes it can be eay to have single function, which can
execute all commands.

Okay?


Now image, that you must be able send to
    vDatabase_SqlQuery()


All SQL commands. And SELECT, and INSERT ..
But what about result?
Result differ for commands, we know this already. Right?


Solution was provide QueryResult -- helper small class, which can keep
 a) cursor
 B) ULONG
 c) something else if needed, for example String, which can be XML.


If you get to hands QueryResult, then what you need do?
Ofcourse you need ask it:
            QueryResult ->  What is inside of you?


And when you will know what is inside, e.g. Cursor,
You will have code 
                   cursorRef = queryResult.get_Cursor()



================
I will check docs and pages you point now.

But again -- do not user QueryResult()

Use SqlSelect() ...

For your task with SHOW DATABASES this the the best choice.



-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list