question

Hoang Nk avatar image
0 Likes"
Hoang Nk asked Jason Lightfoot commented

Executing a stored procedure in SQL server

Hi guys,

I have a question related to SQL server.

The idea for my AGV is that Flexsim will execute a stored procedure in our database using the query "EXEC", that stored procedure will then return either 1 or 0, which means the AGV can/cannot start moving. However, I'm struggling with how to receive the return value of the stored procedure, simply running the "EXEC" query doesn't return anything.

Many thanks in advance!


FlexSim 23.1.3
sql queries
· 4
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

You want to communicate with a server, then I would look for such answers here at this site:

  • JSON
  • Socket
  • Python
  • DLL

https://docs.flexsim.com/en/23.1/Reference/DeveloperAdvancedUser/ConnectingToExternalCode/ConnectingToExternalCode.html

0 Likes 0 ·
Hoang Nk avatar image Hoang Nk Joerg Vogel commented ·

I can normally use these commands for example to execute a procedure in my database:

Database.Connection con = Database.Connection("DatabaseConnector1");
con.connect();
con.query("EXEC dbo.del_simdata");

This time I would like to execute another procedure similarly, the only difference is that I would like to somehow receive the return values of that procedure. Is there a way for that?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Hoang Nk commented ·
If the database.Resultset doesn't contain the return value then can you alter the stored procedure to add a record to another table that you can then read after executing the stored procedure (as a workaround).
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Hoang Nk,

We haven't heard back from you. Were you able to solve your problem? If so, please add and accept an answer to let others know the solution. Or please respond to the previous comment so that we can continue to help you.

If we don't hear back in the next 3 business days, we'll assume you were able to solve your problem and we'll close this case in our tracker. You can always comment back at any time to reopen your question, or you can contact your local FlexSim distributor for phone or email help.

0 Likes 0 ·

0 Answers