I have several connection strings in an app with a variable called vSchema which holds values such as “xyz”.
I need to concatenate a statement to produce the results:
Your “best” option is to use Introspection to search the target object for a matching method or property, then invoking. It’s not necessarily simple, but it’s possible. Otherwise, you’d have to use a Select Case statement and code-in every possible xyz value.
Alpha Anywhere is the tool, xbasic is the language. Yeah, xbasic is an interpreted language. Of course, eval() lives in JavaScript too, which also is interpreted.
Are those different schemas for the same database (e.g. PostgreSQL) or even different schemas in different databases (e.g. some in MySQL and some SQLite)? Whatever you are thinking, maybe there’s a functional “another way” of doing it. Something like:
rs = MultiDBSelect(theDB, theSchema, theSelect)
In your function code you can select the proper Database connection, use it to send an “USE theSchema” command (or “SET search_path TO theSchema,public;” for Postgresql; or another proper way to another one), and then query and return the SELECTed recordset.
[quote=455024:@Jean-Yves Pochez]may be you could try this example and adapt it to your needs. https://forum.xojo.com/37675-expression-evaluator-class/0[/quote]
The ExpressionEvaluator class only works on mathematical expressions. From what I’ve read from the initial post, it looks as if the expression involves string operations. So the ExpressionEvaluator class would not be of any use here. XojoScript is the closest thing to an eval function. There is no question that it could assemble the SQL query. The question is whether you can do the actual database access from within XojoScript.