Forum Home › Forums › Development and Integration › Database SQL usage
Tagged: SQL
- This topic has 18 replies, 3 voices, and was last updated 8 months, 3 weeks ago by
Nguyen.
-
AuthorPosts
-
May 31, 2021 at 3:23 pm #9007
Han
ParticipantI 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 11 months, 3 weeks ago by
Han.
June 1, 2021 at 2:08 pm #9013Mikhail
ModeratorHello,
What module of Rapid SCADA do you use to execute this SQL request?
What DBMS type?June 2, 2021 at 3:27 am #9016Han
ParticipantMicrosoft SQL Server,KpDbImport,thank you !
June 2, 2021 at 1:53 pm #9020Mikhail
ModeratorMicrosoft 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 #9021Mikhail
ModeratorThere is also ModDbExport module. You should compare it with KpDbImport.
June 3, 2021 at 5:27 am #9025Han
ParticipantSorry, 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 11 months, 2 weeks ago by
Han.
June 3, 2021 at 5:37 am #9027June 3, 2021 at 2:25 pm #9032Mikhail
ModeratorSomething 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 #9100Han
ParticipantMicrosoft SQL Server,KpDbImport or ModDBExport;Could you provide the following example ?Thank U
June 16, 2021 at 2:32 pm #9102Mikhail
ModeratorPerform 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 #9127Han
Participant2021-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 #9128Han
ParticipantHow to declare variables?
June 22, 2021 at 3:36 pm #9133Mikhail
ModeratorVariable names are case sensitive. Just copy them from the manual.
June 23, 2021 at 3:24 am #9140Han
ParticipantHi,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 #9141Han
ParticipantI’m sorry, my English is poor, and I don’t know if the grammar I described is correct. I use Google Translate.
-
This topic was modified 11 months, 3 weeks ago by
-
AuthorPosts
- You must be logged in to reply to this topic.