In all of the B4A examples I've seen with SQLite, the app uses a global variable SQL1 that is initialized when the app is started/resumed. This is fine.
But if the app has a lot of nested Subs that need SQL access to tables, they can't all reference the same global SQL1 variable because it may already have a cursor open in another Sub. For example, Sub1 may be looping through Table1 and inside the loop it calls Sub2 that needs to do a lookup to Table2 and also calls Sub3 that updates rows of Table3 etc..
My question is what is the best way to manage multiple SQL variables (so it can handle nested SQL calls)?
TIA
But if the app has a lot of nested Subs that need SQL access to tables, they can't all reference the same global SQL1 variable because it may already have a cursor open in another Sub. For example, Sub1 may be looping through Table1 and inside the loop it calls Sub2 that needs to do a lookup to Table2 and also calls Sub3 that updates rows of Table3 etc..
My question is what is the best way to manage multiple SQL variables (so it can handle nested SQL calls)?
- Do I use a Map that has a list of available SQL variables that are available? (The map contains re-used SQL variables that had been previously used but no longer needed)
- Or do I have each Sub initialize its own local SQL variable when it needs to do some processing or a lookup etc.?
- Is there a better way?
TIA