DB Import string

Forum Home Forums Understanding the Software DB Import string

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #16826
    oley
    Participant

    Hi,

    I use DrvDbImport 6.1.0.1 to communicate with PostgrSQL DB.
    It works, but I become only first 4 characters for string columns.
    I have set the data type of the channel to ASCI and Unicode string and format to String.

    Best regards

    #16827
    manjey73
    Participant

    Specify the required length for the channel, and set the next channel number based on the length of the previous one.
    For example, Channel 200 is a String type, length 2, the next channel should be 202, since you set the length to 2 and occupied channels 200 and 201.

    #16828
    JurasskPark
    Participant
    #16829
    oley
    Participant

    Thank you but I do not really understand that.
    If I will read multiple strings from DB, should they have fixed length?
    Is this length in characters?
    If I have only one string from another table, do I have to create another “dummy” channel to set the length of the previous one?


    @JurasskPark
    I will take a look at this module.

    #16835
    JurasskPark
    Participant

    If I will read multiple strings from DB, should they have fixed length?
    Is this length in characters?

    You must calculate in advance what the maximum length of characters in a string will be. For this maximum length, and book the number of tags / 4 characters.

    #16838
    Mikhail
    Moderator

    Hi,
    Currently long strings are not supported by the DrvDbImport drvier. I hope, we will implement it in the future.
    If the strings have fixed values, they can be presented as numbers, and enumerations can be used.
    Alternatively, use the community driver noticed above.

    #16852
    oley
    Participant

    All right, thank you!

    #17184
    Simon
    Participant

    Hello,
    I’m using Rapid SCADA 6.4 with DrvModbus (Master TCP), and I would like to use the ImportDB module to read commands from a SQL Server table and send them to the PLC (via Modbus TCP holding registers).

    Unfortunately, no commands are executed, and it’s not clear how ImportDB interacts with Devices, Channels, and Commands.
    Could you please provide a complete working example showing how to configure ImportDB to read a table (e.g. rs_cmd) and send a command to a Modbus device?

    1️⃣ SQL Server table example
    CREATE TABLE dbo.rs_cmd (
    Id BIGINT IDENTITY(1,1) PRIMARY KEY,
    CnlNum INT NOT NULL, — Rapid SCADA channel number
    CmdVal FLOAT NULL, — numeric value to write (standard command)
    CmdData VARBINARY(MAX) NULL, — optional binary data (binary command)
    CmdType INT NOT NULL DEFAULT 1, — 1 = Standard, 2 = Binary
    CreateDT DATETIME2 NOT NULL DEFAULT SYSUTCDATETIME(),
    Sent BIT NOT NULL DEFAULT 0, — 0 = pending, 1 = sent
    SentDT DATETIME2 NULL,
    Note NVARCHAR(200) NULL
    );

    Example of inserting a new command:

    INSERT INTO dbo.rs_cmd (CnlNum, CmdVal, CmdType, Note)
    VALUES (582, 100, 1, N’Setpoint command to holding register linked to channel 582′);

    2️⃣ Expected ImportDB behavior

    ImportDB periodically executes a query such as
    SELECT * FROM dbo.rs_cmd WHERE Sent = 0 ORDER BY Id

    It reads CnlNum, CmdVal, CmdData, CmdType, and creates a command for the SCADA Server.

    Rapid SCADA then routes the command to Communicator → Modbus device, performing the write operation (function code 06 or 16).

    After successful execution, ImportDB (or its update query) should set
    Sent = 1, SentDT = GETUTCDATE()
    to avoid re-sending the same command.

    3️⃣ What I would like to clarify

    Table schema expected by ImportDB:
    Are the field names above (CnlNum, CmdVal, CmdData, CmdType) correct for Rapid SCADA 6.4?
    If not, what are the exact column names ImportDB expects (e.g. KPNum, ObjNum, CmdNum, Val, Data, etc.)?
    What are the valid values for CmdType (standard vs binary)?

    ImportDB configuration example:

    Connection string or ODBC setup for MSSQL.

    Example of the SQL select query.

    Field mapping (columns → command properties).

    Update query after successful sending.

    Relation with Modbus device/template:

    How should the Commands section in the Modbus device template be configured so that a Standard Command on CnlNum = 582 actually writes to the corresponding holding register (with proper Modbus address, function code, and byte order)?

    Is the channel number (CnlNum) the correct key that links the DB record to the command in the Modbus device?

    Flow confirmation:

    ImportDB → SCADA Server → Communicator → Modbus TCP device

    Is it correct that no “special” device for ImportDB is required — ImportDB just sends a command to SCADA Server, and the Server forwards it to the existing Modbus device?

    Diagnostics and logging:

    Where can we find detailed ImportDB logs (read row, build command, send result)?

    Is it possible to log the SQL record Id along with the SCADA Command ID for traceability?

    4️⃣ Environment

    Rapid SCADA / Server / Communicator: 6.4.x

    Module: ImportDB

    Driver: DrvModbus TCP (Master)

    Database: Microsoft SQL Server Express 2022

    Goal: write a holding register (e.g., setpoint) for channel 582

    A practical example (SQL + ImportDB config + Device Template Commands) would be extremely helpful to understand the correct workflow for sending commands from a SQL table to a Modbus PLC.

    Thank you in advance for your help and for clarifying the intended usage of ImportDB in this scenario.

    Best regards,
    Simone

    #17189
    Mikhail
    Moderator

    Hi Simone,
    Please follow this manual.
    If you get any errors, post links to the screenshots of the settings and log files written by the module.

    use the ImportDB module to read commands from a SQL Server table and send them to the PLC

    Note that from SQL Server the driver can read values, not commands. Those values will be presented by Rapid SCADA as channel values. To convert values to commands that are send to a Modbus TCP device, Automatic Control Module is needed. The module sends commands according to different conditions, depending on channel values. For example, it can send a command of channel value changes.

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