question

anon-user avatar image
0 Likes"
anon-user asked anon-user commented

 SQL query on global table from c++

Hi,

I would like to know, if there is a way of running an SQL request on a global table in C++. I have seen this old question in the forum: https://answers.flexsim.com/questions/58035/how-to-use-sql-queries-in-a-dll-project.html . Any changes on this?

I have seen the private static method "cpp_query" in the Table class and some public overlays, but am not successful to call them. Can you share an example how to call it properly?

If not, is there a workaround e.g. call/eval a small flexscript from c++?

Kind regards,

Lothar

global tablesqlc++
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ryan Clark avatar image Ryan Clark commented ·

Hi @Lothar K, was Phil BoBo's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Phil BoBo avatar image
0 Likes"
Phil BoBo answered anon-user commented

You can use nodefunction(), function_s(), executefsnode(), or executestring() to execute FlexScript from C++.

· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

anon-user avatar image anon-user commented ·

Thanks a lot for the answer. I will try that workaround. So I assume from your answer, that there is no (public) way to call "Table.query" from C++ directly.

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ anon-user commented ·

There are several C++ query functions that may work better now than when that other question was asked.

There's a visible cpp_query() function in the Engine and a query() macro defined in CppLambdaCommands.h that calls it. I'm not sure whether that is working better now than it used to; it might be.

There's also the static method on the Table class that you mentioned. Try this:

Table table = Table::cpp_query("SELECT * FROM GlobalTable1", CppQueryLambda());
0 Likes 0 ·
anon-user avatar image anon-user Phil BoBo ♦♦ commented ·

Thanks a lot. The CppQueryLambda() made the difference. I failted bedause I tried a nullptr argument there.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.