Joesteva Posted August 14, 2017 Report Share Posted August 14, 2017 Hi, I'm using UniStream with UniLogic (19.2). I'm unsure on how to use the "SQL Query" function block. the "SQL Query" has 3 fields: Query - Input, SQL query to execute. Parameters - Input, query parameter Outputs - Output , query output When I write the next query: Insert into Agua (Tiempo) Values (T_Agua) How does the PLC knows the direction of the database? What do I put in the Parameters and Outputs fields? Is there any file or webinar that I can check regarding this topic? 1 Quote Link to comment Share on other sites More sharing options...
NoamM Posted August 16, 2017 Report Share Posted August 16, 2017 Quote How does the PLC knows the direction of the database? When you are using "SQL Query" function block the first parameter is Query that belongs to an SQL data base. for example: In this example I've created a Query named "My Query" that belongs to data base "Database1". When I will use "SQL Query" function block with "My Query", UniStream will connect to "Database1" according to the specifics I gave it - IP = 1.2.3.4, Port = 1234, etc... Quote What do I have to put on the parameters and output fields? In your case you preforming an "Insert" query, meaning your SQL client (the UniStream) will write data to the SQL Server, so you don't need to assign Outputs tags because no data will return from the server. You do however can see the execution state in your query "SQL Query Struct". In my example I have one "SQL Query Struct" for "My Query": Here I can check if the query executed properly and what is the query status report. Using Outputs - If for example I preformed the next query: Select top 1 PhoneNumbersColumn from MyCustomerTable I'm actually reading data to my SQL client (the UniStream) from my SQL Server, so I should assign Outputs tag for the 1 (due to "top 1") value the server returning. More about SQL in here. Using Parameters - If for example I preformed the next query: Select top 1 PhoneNumbersColumn from MyCustomerTable where CustomerID = @ID I'm requesting my SQL client (the UniStream) to take "@ID" value from my Parameters , and use it in the query. So "@ID" can be changed in each Ladder cycle and I can use the same query to request "PhoneNumbersColumn" according to a dynamic "CustomerID". The "@ID" called a placeholder and you can track your placeholders in this screen: Quote Is there any file or webinar that I can check regarding this topic? There is more information in the UniLogic help: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.