Mitsubishi Electric GX Works3

For Mitsubishi GX Works3 controllers, SQL4automation provides a sample project and a library. The library can either be opened directly as a new project or integrated into an existing project.

Connecting Mitsubishi PLC to SQL Databases, MES, ERP

For Mitsubishi GX Works3 controllers, SQL4automation provides a sample project and a library. The library can be opened directly as a new project or integrated into an existing project. No additional middleware, no OPC UA gateway, and no changes to the Mitsubishi hardware are required. Communication is handled via standard Ethernet TCP/IP. More information is available in video tutorial T010.

Integration of the SQL4GXWorks3 Library

The SQL4GXWorks3 library receives parameters such as the IP address and port of the Connector as well as the SQL string. The return values of the SQL query are written to the stResult structure, giving your Mitsubishi program direct access to database records without any additional parsing layer.

SQL4automation Link Settings

The SQL4automation Connector is operated with the target setting "Standard" for Mitsubishi GX Works3 controllers. The configuration is completed in just a few clicks. Detailed integration instructions and the library download are available in the download section.

FAQ's

Freuqently Asked Questions to Mitsubishi

Can SQL4automation connect a Mitsubishi MELSEC PLC directly to a SQL database?

Yes. SQL4automation provides a dedicated library for Mitsubishi controllers programmed with GX Works3. The library establishes a direct TCP/IP connection between the Mitsubishi PLC and the SQL4automation Connector. No OPC UA server, no database driver on the PLC, and no middleware PC is required beyond the machine running the Connector.

Which Mitsubishi GX Works3 controllers are compatible with SQL4automation?

SQL4automation has been developed and fully tested for the MELSEC iQ-R series (RCPU), including the R04CPU. The MELSEC iQ-F series (FX5CPU), including the FX5U-32M, is supported but has not yet been fully tested due to limited hardware access. Contact us to verify compatibility with your specific FX5CPU model.

How do I integrate the SQL4GXWorks3 library into an existing GX Works3 project?

Register the library to the User Library List in GX Works3. Once added, the SQL4GXWorks3 function blocks appear in the Element Selection window and can be dragged directly into your project. Configure the Connector IP address, port, and SQL string in the function block instance, then call it cyclically in your program.

Does SQL4automation support the Mitsubishi MELSEC iQ-R series?

Yes. The Mitsubishi Electric R04CPU (MELSEC iQ-R series) has been fully tested and verified with SQL4automation. The iQ-R series is programmed with GX Works3 and uses standard Ethernet communication, making it fully compatible with the SQL4GXWorks3 library.

What data does the SQL4GXWorks3 library return from a SQL query?

The library returns results in the stResult structure. iResultState indicates success (0) or an error code. iResultRows and iResultColumns report the dimensions of the result set. For SELECT queries, the full data table is available. For INSERT, UPDATE, and DELETE operations, execution status and error codes are returned. The SQL string is built in the Mitsubishi program, giving full control over query logic.

For which Mitsubishi PLC controllers has SQL4GXWorks3 library been tested?

Mitsubishi Electric R04CPU, Mitsubishi Electric FX5U-32M

Technical Data

REQUIREMENTS & VERSION INFO
Programming environment Melsoft GX Works3 Studio
Tested controller series RCPU (fully tested) and FX5CPU (not yet fully tested due to limited hardware access)
Note on FX5CPU The FX5CPU library has not been fully tested. Contact us before deploying in production environments.
Library integration Open as new project via Project > Open Other Format File, or register to User Library List and drag blocks into existing project via the Element Selection window.
REQUIRED BLOCKS / LIBRARIES
  • SQL4GXWorks3 function block library
  • fbSQL4GXWorks3 function block instance
  • Ethernet interface on the controller
FUNCTION BLOCK PARAMETERS
Parameter Type Description
uaIPaddress ARRAY IP address of the SQL4automation Connector (array of 4 octets)
uPort UINT Port number of the SQL4automation Connector (default: 11001)
wConnection WORD Connection identifier (default: 3)
uLocalPort UINT Local port used on the controller (default: 1234)
xHoldConnection BOOL Keeps the connection open after a database query (default: FALSE)
tTimeout TIME Communication timeout (default: T#30S)
wMaxParams WORD Maximum number of return parameters (default: 16)
wMaxRows WORD Maximum number of rows in the response table (default: 16)
wMaxColumns WORD Maximum number of columns in the response table (default: 16)
wMaxStringLength WORD Maximum string length in the response (default: 255)
wMaxBytes WORD Maximum buffer size in bytes (default: 4096)
stResult.iResultState INT Output: status / error code (0 = no error)
stResult.iResultRows INT Output: number of rows returned
stResult.iResultColumns INT Output: number of columns returned
ERROR CODES (diResultState)
Error Code Description
1 Unknown SQL command
2 Query returns more records than MaxRows. Adjust query or increase MaxRows.
3 Query returns more columns than MaxColumns. Adjust query or increase MaxColumns.
5 Query returns at least one value larger than MaxStringLength. Adjust query or increase MaxStringLength.
10 Internal Connector error
11 Internal Connector error; database cannot be opened
21 No IP address defined for PLC and/or Connector
22 No port number defined
23 MaxParams not defined
24 MaxRows not defined
25 MaxColumns not defined
26 MaxStringLength not defined
27 MaxBytes not defined
41 Error opening the controller port
42 No connection to SQL4automation Connector. Check firewall and license.
51 Error during sending of request
61 Error during receiving of response
99 Timeout: no response from the Connector within the time window
>100 ODBC database connection error codes
40002 General error in the SQL query; request string is invalid

Switch to SQL4automation Now.

Connect industrial controllers directly with SQL databases. Field-proven since 2007 for maximum performance and security, completely without middleware.

Mitsubishi Electric GX Works3
by Industry.