Database SQL usage

Forum Home Forums Development and Integration Database SQL usage

Tagged: 

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #9007
    Han
    Participant

    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.
    #9013
    Mikhail
    Moderator

    Hello,

    What module of Rapid SCADA do you use to execute this SQL request?
    What DBMS type?

    #9016
    Han
    Participant

    Microsoft SQL Server,KpDbImport,thank you !

    #9020
    Mikhail
    Moderator

    Microsoft 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?

    #9021
    Mikhail
    Moderator

    There is also ModDbExport module. You should compare it with KpDbImport.

    #9025
    Han
    Participant

    Sorry, 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.
    #9027
    Han
    Participant
    #9032
    Mikhail
    Moderator

    Something 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.

    #9100
    Han
    Participant

    Microsoft SQL Server,KpDbImport or ModDBExport;Could you provide the following example ?Thank U

    #9102
    Mikhail
    Moderator

    Perform the settings according to the manual. In case of errors provide screenshots of the settings and error messages.

    #9127
    Han
    Participant

    2021-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 request

    #9128
    Han
    Participant

    How to declare variables?

    #9133
    Mikhail
    Moderator

    Variable names are case sensitive. Just copy them from the manual.

    #9140
    Han
    Participant

    Hi,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.

    #9141
    Han
    Participant

    I’m sorry, my English is poor, and I don’t know if the grammar I described is correct. I use Google Translate.

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.