Connection parameter passed as 'variable' to internal libraries, causes errors in macros sc_exec_sql, sc_lookup, sc_select

Gentlemen of Scriptcase below, I paste a post that was published in June 2013, and in July 2023 it has not yet been resolved or answered. 10 years! How much longer do we have to wait?

The Internal and External Libraries are basically used as reusable code, so it is logical that your functions expect input variables to produce common processes, used from different Project applications.

------- POST 2013 ------------

"When specifying the 2nd parameter for this macro, ScriptCase will generate a PHP error unless the value is hard-coded.
sc_exec_sql (“SQL Command”, “Connection”)

For example, these lines of code crashes PHP:
sc_exec_sql ($sql_command, [global_my_connection]);
sc_exec_sql ($sql_command, $thisConnection);

The same is true for the other functions I listed, when they are used in Library functions.

When used in Library functions, the PHP error I get is:
Parse error: syntax error, unexpected ‘,’ in E:\Program Files\NetMake\v7\wwwroot\scriptcase\app rialshow\Login\Login_apl.php on line 1384

It will generate a different type of error in the Events. For example, this works fine:
sc_select(my_data, “SELECT DISTINCT Access FROM myusers WHERE LoginID=‘johnxm’”, “si_local_mysql”);

BUT if I change it to:
[global_ftp_db] = ‘si_local_mysql’;
sc_select(my_data, “SELECT DISTINCT Access FROM myusers WHERE LoginID=‘johnxm’”, [global_ftp_db]);

Then I get a error on compile:

SQL ERROR’s:
Event onValidate: “SELECT DISTINCT Access FROM myusers WHERE LoginID='johnxm”, [global_ftp_db]
(Table 'sc_XXXXXXXXXX_dev.myusers ’ doesn’t exist)
(screenshot of one time I had this error is attached)

Why this is really bad for me: We have to frequently switch the database that our code uses. We need to coordinate a central database with 5-10 other servers that each run a local mySQL. I think it’s pretty common to need to use multiple connections. So I think this is a really important bug fix."

Dear @Intercore,

According to the Scriptcase documentation, the macros mentioned by you in the topic title, it is not possible to use variables in the macro connection parameter, being necessary to insert the connection name directly.

Although it is not a Scriptcase bug, I will report the case as an improvement to be implemented, aiming at an ease and better experience for the developer.

Thank you for your collaboration and feedback, and any news about the case, I’ll give you a feedback through this topic.

Best regards!

Thank you very much for your reply.

I agree that in the sc_lookup and sc_select macros there is a note indicating that the connection parameter has to be “explicit” not a variable. There is no note in sc_exec_sql, (which is the one I use the most) but hey…

Scriptcase must understand that, a change of connection in SQL statements of a Common Library is fundamental for those projects (like mine) multi DB. Sending variables greatly facilitates the use of recurring scripts. Therefore I ask Scriptcase to consider this improvement in their SQL macros.

Thank you