Forum Home › Forums › Development and Integration › Database SQL usage
Tagged: SQL
- This topic has 18 replies, 3 voices, and was last updated 2 years, 7 months ago by Nguyen.
-
AuthorPosts
-
May 31, 2021 at 3:23 pm #9007HanParticipant
I have a question about SQL.
“INSERT INTO dbo.PN1 (triggertime,iiot_PN1_A1,iiot_PN1_A2,iiot_PN1_A3,iiot_PN1_A4)
VALUES ( , , , , );” How to associate the value of the variable?
Are there any system default variables? Similar to the system time, it can be used directly.- This topic was modified 2 years, 10 months ago by Han.
June 1, 2021 at 2:08 pm #9013MikhailModeratorHello,
What module of Rapid SCADA do you use to execute this SQL request?
What DBMS type?June 2, 2021 at 3:27 am #9016HanParticipantMicrosoft SQL Server,KpDbImport,thank you !
June 2, 2021 at 1:53 pm #9020MikhailModeratorMicrosoft SQL Server definitely provides a current time function. You should google it on database forums.
If you use KpDbImport for sending commands, it supports @cmdVal and @cmdNum parameters of the SQL statement for command value and command number.
What is the generalized task you need to resolve?
June 2, 2021 at 1:54 pm #9021MikhailModeratorThere is also ModDbExport module. You should compare it with KpDbImport.
June 3, 2021 at 5:27 am #9025HanParticipantSorry, I am a novice, can you provide the usage of @cmdVal and @cmdNum. I want to write the value read by modbus into SQL, for example, write the value of channel 101 of modbus into SQL?
- This reply was modified 2 years, 10 months ago by Han.
June 3, 2021 at 5:37 am #9027June 3, 2021 at 2:25 pm #9032MikhailModeratorSomething like
insert into mytable field1 values (@cmdVal)
A command contains only one value.
You should try. In case of errors, you could send links to screenshots and post logs.June 16, 2021 at 2:14 pm #9100HanParticipantMicrosoft SQL Server,KpDbImport or ModDBExport;Could you provide the following example ?Thank U
June 16, 2021 at 2:32 pm #9102MikhailModeratorPerform the settings according to the manual. In case of errors provide screenshots of the settings and error messages.
June 22, 2021 at 2:34 pm #9127HanParticipant2021-06-22 22:32:13 Establish a TCP connection with :1433
2021-06-22 22:32:13 Communication session with the Device 2 “SQL2008”, type: KpDbImport
Data request
Error executing query: scalar variable “@CnlNum” must be declared.
Data request
Error executing query: scalar variable “@CnlNum” must be declared.
Data request
Error executing query: scalar variable “@CnlNum” must be declared.
Data requestJune 22, 2021 at 2:35 pm #9128HanParticipantHow to declare variables?
June 22, 2021 at 3:36 pm #9133MikhailModeratorVariable names are case sensitive. Just copy them from the manual.
June 23, 2021 at 3:24 am #9140HanParticipantHi,Mikhail
Thank you for your help all the time.
Sorry, I failed to describe my needs clearly before. I want to write the data (data1, data2, data3…) obtained by Modbus into the SQL table at a frequency of once a minute. The columns of the SQL table are arranged in accordance with the (writing time, data1, data2, data3… ).Retrieving data from Modbus has been successful. But I don’t know how to write SQL in the above arrangement.June 23, 2021 at 3:27 am #9141HanParticipantI’m sorry, my English is poor, and I don’t know if the grammar I described is correct. I use Google Translate.
-
AuthorPosts
- You must be logged in to reply to this topic.