sqlyoga_Reset: when things get messed up :)

This is the place to post technical queries about SQL Yoga

Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, trevordevore

Post Reply
trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

sqlyoga_Reset: when things get messed up :)

Post by trevordevore » Fri Oct 11, 2013 1:52 pm

[This post is an archive from old SQL Yoga forums]

When you've messed things up - it would be nice to be able to "sqlyoga_Reset"

Handlers such as sqlyoga_getDatabases(), sqlyoga_getDefaultDatabase(), dbobject_GetArrays() must I guess store their values as script locals in the locked sqlYoga library. So there is no global we can manually reset, and we are forced to restart Revolution - or at least I think it is the only way. It can be a little hard working out what is going on with locked stacks, so it would be nice to have an explanation of where things like dbobject_GetArrays() are stored - and preferably have not just "get" but "set" and "delete" for all these things?

Background - in case you want to know how I messed up :)

When debugging an issue with not being able to delete records, I got myself into a mess. I tried to create a database object which was not named "default" - so I could look at the example code while working on my db, and tried to manually clone the array, with code that looks like:

Code: Select all

on menu_CloneDatabase dbKey

put dbobject_GetArrays() into yogaArrays

put dbobject_Get ("storage object") into storageObject

-- get the uSQLDatabaseObject of storageObject

put "Copy of" && dbKey into newName

put opn_Ask ("What do you want to call the new database?", newName) into newDBKey

put yogaArrays [dbKey] into yogaArrays [newDBKey]

display_Array yogaArrays

set the uSQLDatabaseObject of storageObject to yogaArrays

end menu_CloneDatabase
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Location: Overland Park, Kansas
Contact:

Re: sqlyoga_Reset: when things get messed up :)

Post by trevordevore » Fri Oct 11, 2013 1:52 pm

Hi David,

All information is stored within script locals in the locked library. I have no plans to move to globals for storage as I don't want people messing with them outside of the API :-)

This should not be a problem though as dbobject_getArrays() returns the script local variable as-is so you can see exactly what is stored there.

If you want to start fresh with a database object just call dbobject_deleteObject and start over. No big deal.

Your code doesn't work because the uSQLDatabaseObject stores ONE database object, not multiple. You are assigning an invalid array to that property so my guess is SQL Yoga barfs on the array it tries to load from the uSQLDatabaseObject.

Here is a way to do what you want using the API (which should be much safer):

Code: Select all


## Get existing db object

put dbobject_getArray("default") into theDBArray

## create new db object

dbobject_createFromArray theDBArray, "copy of default"

## Update storage location

dbobject_set "storage object", the long id of "SomeOtherButton", "copy of default"

dbobject_save "copy of default"

Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Post Reply

Return to “SQL Yoga”