Close all open databases -- VDataBase_Open()

william humphrey bill at bluewatermaritime.com
Mon Oct 14 13:26:11 CDT 2013


You're right. To close a database you use something like this:

*function* DBClose isDestructing

   *get* VDatabase_Close( lDatabase )

   *if* isDestructing = true *then*

      *put* VDatabase_Destructor( lDatabase ) into lDatabase

   *end* *if*

   *put* "Database Closed" into field error_field



*end* DBClose


So what we need after calling the SQL to get list of the names of open
databases is a function that looks up the ID of an open database based on
the name. I usually have two databases open in my projects but I have them
open in different stacks and I store the ID in a global variable and thus
am able to close it -- usually right before I close each one of the stacks.


There is a function


  get Valentina_Database( inIntIndex ) into dbRef


  Returns a database from the array of databases by an index.


I'm not sure if this function will help as I've never figured out how to
use it. I have used:

  Valentina_DatabaseCount() (r/o)

Returns: integer
Returns the count of databases that was instantinated in your application.
The result counts

both opened and closed databases. The result counts both local and remote
databases.

Example:

get Valentina_DatabaseCount







On Mon, Oct 14, 2013 at 10:04 AM, Mark Schonewille <
m.schonewille at economy-x-talk.com> wrote:

> Hi everyone,
>
> Now that I know how to execute the SHOW DATABASES query, using the script
>
> function queryTest
>    put VDatabase_SqlSelect(lDatabase,**"SHOW DATABASES") into myCursor
>    // put vDatabase_SqlQuery(lDatabase,"**SHOW DATABASES") into myCursor
>    put VCursor_RecordCount(myCursor) into myRecordCount
>    put VCursor_GetRecords(myCursor,1,**myRecordCount,tab,cr) into myData
>    put VCursor_Destructor(myCursor) into myCursor
>    return myData
> end queryTest
>
> which we discussed before, (i.e. without the syntax causing the crash), it
> occurs to me that contrary what Ruslan argues no database ID's or cursors
> are returned. So, the question remains:
>
> how do I get a list of all open databases, for use in a repeat loop that
> closes all databases, like so:
>
> put valentina_openDatabases() into myOpenDatabases
> repeat for each item myDatabase in myOpenDatabases
>   get vDatabase_Close(myDatabase)
> end repeat
>
> (Keep in mind that I made up this syntax, there is no
> valentina_openDatabases() function).
>
>
>
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> Homepage: http://economy-x-talk.com
> Twitter: http://twitter.com/**xtalkprogrammer<http://twitter.com/xtalkprogrammer>
> KvK: 50277553
>
> Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other colour
> spaces. http://www.color-converter.com
>
> Buy my new book "Programming LiveCode for the Real Beginner"
> http://qery.us/3fi
>
> Fill out this survey please
> http://livecodebeginner.**economy-x-talk.com/survey/<http://livecodebeginner.economy-x-talk.com/survey/>
>
> On 10/13/2013 17:48, Ruslan Zasukhin wrote:
>
>> On 10/13/13 5:34 PM, "william humphrey" <bill at bluewatermaritime.com>
>> wrote:
>>
>>  I looked through that PDF and did not find any command which lists the
>>> names
>>> of the open databases.
>>>
>>
>> This can be done via SQL
>>
>>      SHOW DATABASES
>>
>> You get cursor, iterate it, get names
>>
>>
>>  ______________________________**_________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/**mailman/listinfo/valentina<http://lists.macserve.net/mailman/listinfo/valentina>
>



-- 
http://www.bluewatermaritime.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macserve.net/pipermail/valentina/attachments/20131014/1f2e405c/attachment.html>


More information about the Valentina mailing list