Appendix A
A-44
NJ/NX-series Database Connection CPU Units User’s Manual (W527)
Sample Programming
- Establish a DB Connection named MyDatabase1 and map a table with a variable.
Check the completion of DB_Connect and DB_CreateMapping instructions.
DB_CreateMapping
_Select_instance.Done
DB_Connect_instance.Error
DB_CreateMapping_Select
_instance.Error
Accept the trigger for establishing the DB Connection.
Establish the DB Connection named MyDatabase1.
Done
Busy
Error
ErrorID
DBConnection
Map the variable MapVar_Select to the table Production of the DB Connection MyDB1 for the SELECT operation.
DB_CreateMapping
_Select_
instance
MyDB1
‘Production’
MapVar_Select
_DBC_SQLTYPE_SELECT
Execute
DBConnection
TableName
MapVar
SQLType
When the instruction is terminated due to an error, execute the error handler for the device (FaultHandler_Connect).
Program the FaultHandler_Connect according to the device.
DB_Connect_instance.Error
DB_CreateMapping_Select_instance.Error