Home

NJ-series Database Connection CPU Units User's Manual

image

Contents

1. Event name DB Connection Service Run Mode Change Failed Event code 5401 3001 hex Meaning Failed to change the Run mode of the DB Connection Service Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction Run mode change to Test Mode Stop the DB Connection Service Write the user program so that the was executed by the relevant and then execute the relevant relevant instruction is executed instruction while running in instruction Or correct the user when the operation status of the Operation Mode program so that the relevant DB Connection Service is Idle Run mode change to Operation instruction is executed when the Mode was executed by the operation status of the DB relevant instruction while running Connection Service is Idle in Test Mode Start of the DB Connection Execute the relevant instruction While a DB_Insert DB_Update Service was commanded while later DB_Select or DB_Delete the DB Connection Service was instruction is being executed the being stopped DB Connection Service becomes Shutdown of the DB Connection stopping status If stop of the DB Service was commande
2. Name Data type Initial value Comment _DBC_Status _sDBC_STATUS System defined variable that shows the status of the DB Connection Service DB_Connect_instance DB_Connect Instance of DB_Connect instruction MyDB1 DWORD a This variable is assigned to the DBConnection output variable from DB_Connect_instance Trigger_Connect BOOL FALSE Variable used as a trigger for establishing a DB Connection LastTrigger_Connect BOOL FALSE Variable to retain the trigger status of the previous execution Operating_Connect BOOL FALSE The DB_Connect instruction is executed when this variable is TRUE OperatingStart_Connect BOOL FALSE The start processing for establishing the DB Connection is executed when this variable is TRUE DB_CreateMapping_Insert_instance DB_CreateMapping Instance of DB_CreateMapping instruction MapVar_Insert PRODUCTION_INSE This variable is assigned to the MapVar input RT variable to DB_CreateMapping_Insert_instance DB_Insert_instance DB_Insert Instance of DB_Insert instruction Name STRING 256 WORKO001 Production information Product name LotNo UINT 1234 Production information Lot number Trigger_Insert BOOL FALSE Variable used as a trigger for inserting DB records LastTrigger_Insert BOOL FALSE Variable to retain the trigger status of the previous execution Operating_Insert BOOL FALSE The DB_Insert instruction is executed when this variable is TRUE OperatingStart_Insert BOOL FALSE
3. KR j INSERTS EtherNet IP vl 2 Recovery DB reconnected a SQL statement is automatically spooled in the case of failure I EM Area b When communications are recovered i e when non volatile memory the DB is reconnected the SQL statements in the Spool memory are resent automatically or by Spool Memory executing an instruction INSERT INSERT INSERT a When a failure occurred in information exchange between DB Connection Service and DB the unsent SQL statements are automatically stored in the Spool memory EM Area b When communications are recovered from the failure and the DB is reconnected the SQL statements in the Spool memory are resent automatically or by executing an instruction 5 1 3 Applicable Instructions and Spooling Execution Conditions 5 2 Applicable Instructions The following two instructions are applicable to this function DB_Insert Insert DB Record instruction DB_Update Update DB Record instruction l Precautions for Correct Use Only the processing for inserting or updating records is spooled For the other processing you need to execute the instruction again e If an instruction error SQL Execution Error occurs the transmitted SQL statement itself can be the cause of the SQL Execution Error Therefore the SQL statement is not stored in the Spool memo
4. Variables O l 5 i Input Variables D la Name Meaning Data type Valid range Unit Default Description 9 Execute Execute BOOL TRUE or FALSE FALSE Specify the execution gt condition 3 O DBConnection DB connection DWORD 16 00000000 to Specify the DB S 16 FFFFFFFF connection established aA by a DB_Connect instruction Cmd Command _ eDBC_SPOOL _DBC_SPOOL_CLEAR 1 0 Specify the command to _CMD Clear execute o _DBC_SPOOL_RESEND 2 i e Resend D O S i Output Variables 2 Seen eT e a nc nn TT Q Name Meaning Data type Valid range Unit Description Q ip Done Done BOOL TRUE or o TRUE when the instruction is normally D FALSE completed Busy Executing BOOL TRUE or TRUE when the instruction is being executed O FALSE D Error Error BOOL TRUE or TRUE when the instruction is terminated due to S FALSE an error Q ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 3 16 FFFF 8 5 KA v Z u NJ series Database Connection CPU Units User s Manual W527 A 71 Appendix A Related System defined Variables _EIP_EtnOnlineSta Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used Related Error Codes Error code Meaning Description 0400 hex Input Value Out of Range A value that is not defined as an enumerator was specified in the Cmd input vari
5. Event name DB Connection Rejected Event code 5401 3004 hex Meaning The DB rejected the connection Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction The user name or password set Enter the correct user name and Enter the correct user name and in the DB Connection settings is password in the DB Connection password in the DB Connection wrong settings settings Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks Event name DB Connection Failed Event code 5401 3005 hex Meaning Failed to connect to the DB Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes L
6. 5 D NJ series Database Connection CPU Units User s Manual W527 6 21 6 How to Use Operation Logs 6 5 SD Memory Card Operations 6 5 1 6 5 2 6 22 In the DB Connection Service the SD Memory Card mounted in the CPU Unit is used for the Operation Log function The Execution Log files Debug Log files and SQL Execution Failure Log files are stored in the SD Memory Card This section describes how to save the log files on the SD Memory Card and precautions for replacing the SD Memory Card Refer to the NJ series CPU Unit Software User s Manual W501 for details of the SD Memory Card functions Saving Operation Log Files on SD Memory Card Each Operation Log file is stored in the SD Memory Card in the following conditions Operation Logs Operation to use the function Conditions for saving log files on SD Memory Card Execution Log Set Execution log to Record in the DB Constantly saved while the DB Connection Connection Service Settings of Sysmac Service is running Studio Debug Log Right click the DB Connection Service Constantly saved while the Debug Log is Settings in the Multiview Explorer on recorded Sysmac Studio and select Online Settings from the menu Then click the Start Button for Debug Log in the Online Settings Tab Page Or Execute a DB_ControlService Control DB Connection Service instruction to start recording to the Debug Log SQL Execution Set SQL execution failure log to R
7. Checking method What you can check Checking the indicators CPU Unit operating status Troubleshooter of Sysmac Studio You can check for current Controller errors a log of past Controller errors error sources error causes corrections and error log of CJ series Special Units Checking with the Troubleshooter of an You can check for current Controller errors a log of past Controller NS series PT errors error sources causes and corrections Checking with instructions that read function You can check the highest level status and highest level event code module error status in the current Controller errors Checking with system defined variables You can check the current Controller error status for each function module 1 Detailed information such as error causes and corrections are not displayed 2 To perform troubleshooting from an NS series PT connect the PT to the built in EtherNet IP port on the CPU Unit Py This section describes the above checking methods rs Q Checking the Indicators S paa a You can use the PWR indicator on the Power Supply Unit and the RUN and ERROR indicators on the CPU Unit to determine the event level for an error The following table shows the Q relationship between the Controller s indicators and the event level a fe a Indicator CPU Unit operating status Error confirmation with Sysmac PWR RUN ERROR Studio or an NS series PT 7 Not lit
8. Execution of SQL statement refers to the execution of DB_Insert Insert DB Record DB_Update Update DB Record DB_ Select Retrieve DB Record or DB_Delete Delete DB Record instruction or resending of Spool data automatically or manually by executing a DB_ControlSpool instruction NJ series Database Connection CPU Units User s Manual W527 4 13 uolJosuUOD gq JO SNIS ey BuryoayD p UOI O9UUOD gq y22 pue JMS UOHoeUUOD gq Yoke JO sN els y BuryoeyD v E p 4 Basic Operations and Status Check i Checking the Status using a Get DB Connection Status Instruction You can check the connection status and information of each DB Connection using a DB_GetConnectionStatus Get DB Connection Status instruction Information Description Connection status of the DB Connection status Closed Connected or Disconnected of the DB Connection Connection Connection Connected time Total time when the DB is connected information This value is cleared when the status changes from Closed to Connected of the DB Disconnected time Total time when the DB is disconnected Connection This value is cleared when the status changes from Closed to Connected Number of normal Number of times when an SQL statement is normally executed executions Including the number of times when a spooled SQL statement is resent This value is cleared when the DB Connection Service is started Number of error Number of times wh
9. Possible causes The following can be the causes 1 The sufficient processing time may not be allocated to the DB Connection Service that is executed as a system service due to execution of communications or SD Memory Card processing e Countermeasures 1 Reconsider the task design so that the sufficient execution time can be allocated to the system services in reference to B 1 3 Guideline for System Service Execution Time Ratio NJ series Database Connection CPU Units User s Manual W527 B 7 SUO ONISU UOIIO9UUOD gq JO sul UONINDExy z g suolonusu UOI 9UUOD gd 40 Sul YUOINDSXy 0 SUO NOISSY z a Appendix B i Phenomenon 4 Execution Time of DB Connection Instructions is Steadily Long e Possible causes The following can be the causes 1 The sufficient execution time may not be allocated to the system services Countermeasures 1 Reconsider the task design so that the sufficient execution time can be allocated to the system services in reference to B 1 3 Guideline for System Service Execution Time Ratio Phenomenon 5 Depending on the DB s Status Execution Time of a DB Connection Instruction i e DB_Insert DB Update DB Select or DB_Delete Instruction Got Longer e Possible causes The following can be the causes 1 Load on the server was temporarily increased 2 The specified table contains many records 3 The data clear operation was executed for the specified table 4 The specified t
10. NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 4 4 Checking the SQL Execution Failure Log Refer to 6 6 Checking the Operation Logs for how to check the SQL Execution Failure Log 6 4 5 SQL Execution Failure Log File Specifications This section describes the specifications of SQL Execution Failure Log files Each SQL Execution Failure Log file is composed of multiple records Each record is expressed in one line The maximum size of each SQL Execution Failure Log file is set on Sysmac Studio The size of each record is 58 KB max The following table shows the file name and type File name File type DB_SQLFailedLog log Latest log file of the log DB_SQLFailedLog_ year_month_date_hours_minutes_seconds_milliseconds log Previous log files Example DB_SQLFailedLog_20120724220915040 log DB_SQLFailedLog fjc Log control file The system time of the CPU Unit is used for the time information included in the file name The files are stored in the following directory of the SD Memory Card Log files packages DB_Connection SQLFailedLog Log control file packages DB_Connection System The following is the format of records Each record is expressed in one line and composed of multiple parameters The parameters are separated from each other by a tab 607 aunjre4 uono x4 TOS v 9 Serial number lt tab gt Date lt tab gt Time lt tab g
11. lt value gt Where ColumnB LIKE ABC When the Spool function is enabled the SQL statement is stored in the Spool memory in the following cases In these cases DBC_SEND_SPOOLED is set in the SendSitatus output variable and the instruction is terminated due to an error When the DB records cannot be updated due to a network failure or other causes DB Connection Disconnected Error Status When the DB records cannot be updated within the time specified in the TimeOut input variable DB Connection Instruction Execution Timeout If an instruction error SQL Execution Error occurs when the Spool function is enabled the transmitted SQL statement itself can be the cause of the SQL Execution Error for example due to a retrieval condition setting error Therefore the SQL statement is not stored in the Spool memory because the SQL Execution Error may occur again when the SQL statement is resent When the Spool capacity for each DB Connection is exceeded by spooling the SQL statement this instruction is terminated due to an error Spool Capacity Exceeded A 20 NJ series Database Connection CPU Units User s Manual W527 Appendix A Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of
12. Connection NJ series Database Connection CPU Units User s Manual W527 Appendix A Sample Programming Establish a DB Connection named MyDatabase1 and map a table with a variable Start the sequence when the variable Trigger_Connect changes to TRUE IF Trigger_Connect TRUE AND LastTrigger_Connect FALSE AND _DBC_Status Run TRUE THEN OperatingStart_Connect TRUE Operating_Connect TRUE END_IF LastTrigger_Connect Trigger_Connect Sequence start processing IF OperatingStart_Connect TRUE THEN Initialize the instances of the applicable DB Connection Instructions DB_Connect_instance Execute FALSE DB_CreateMapping_Select_instance Execute FALSE MapVar MapVar_Select SQLType _DBC_SQLTYPE_SELECT J uW QO O 3 5 oO QO O 5 gt A 2 c QO O 3 na Stage 1 OperatingStart_Connect FALSE END_IF Establish the DB Connection named MyDatabese1 Map the variable MapVar_Select to the table Production of the DB Connection MyDB1 for the SELECT operation 9 IF Operating_Connect TRUE THEN D CASE Stage OF 5 1 Establish the DB Connection 2 DB_Connect_instance D Execute TRUE DBConnectionName MyDatabase1 p DBConnection gt MyDB1 8 Q IF DB_Connect_instance Done TRUE THEN Stage INT 2 Normal end END_IF IF DB_Connect_instance Error TRUE THEN Stage INT 99 Error END_IF 2 Map the DB table with the var
13. Data Backup Restore Available Remarks function operations DB Connection Supported Backup Restore Data group in the backup function is User settings program and settings Event log Backup only Data group in the backup function is Event log Operation Logs Not supported Refer to the Additional Information below Spool data The Spool data is cleared by the Restore operation The Restore operation cannot be performed in the following cases When any of the following is applicable the DB Connection settings cannot be restored The Restore Operation Failed to Start event is registered into the event log when the Restore operation is executed You attempt to restore the data from a CPU Unit other than NJ501 10 does not support the DB Connection Service to an NJ501 1 that supports the DB Connection Service lt You attempt to restore the data from an NJ501 1 the DB Connection Service to a CPU Unit other than NJ501 1 not support the DB Connection Service The Unit version of the restore destination CPU Unit is earlier than the Unit version of the backup source CPU Unit The restore operation can be performed between the NJ501 1 20 i e a model that 20 CPU Unit i e a model 20 CPU Unit i e a model that supports 20 i e a model that does 20 CPU Units that support the DB Connection Service even if the model number i e the numbe
14. NJ series Database Connection CPU Units User s Manual W527 Regulations and Standards License Rights We grant you a nonexclusive nontransferable limited license to use the programs a for purposes of developing testing prototyping and running applications you have developed for your own internal data processing operations b to distribute the programs with applications you have developed to your customers provided that each such licensee agrees to license terms consistent with the terms of this Agreement you do not charge your end users any additional fees for the use of the programs and your end users may only use the programs to run your applications for their own business operations and c to use the programs to provide third party demonstrations and training You are not permitted to use the programs for any purpose other than as permitted under this Agreement If you want to use the programs for any purpose other than as expressly permitted under this agreement you must contact us or an Oracle reseller to obtain the appropriate license We may audit your use and distribution of the programs Program documentation is either shipped with the programs or documentation may accessed online at http www oracle com technetwork indexes documentation index html Ownership and Restrictions We retain all ownership and intellectual property rights in the programs You may make a sufficient number of copies of the programs for the licens
15. 4 3 2 Checking the Status of the DB Connection Service You can use the following methods to check the status of the DB Connection Service DB Connection Service Monitor of Sysmac Studio DB_GetServiceStatus Get DB Connection Service Status instruction System defined variable Checking the Status with DB Connection Service Monitor of Sysmac Studio Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Monitor DB Connection Service from the menu while online with an NJ series CPU Unit Edit Online Settings Monitor DB Connection Service The following DB Connection Service Monitor Tab Page is displayed A Configurations and Setup A Service Settings v Operation Information Operation status Running Operation Mode Operating time 0 00 01 42 v Operation Log Debug lng OFF w Query Execution Number of normal executions 0 Number of error executions 0 vYSpooling Number of spuul data 0 4 8 NJ series Database Connection CPU Units User s Manual W527 4 Basic Operations and Status Check You can check the following in the monitor unless the operation status of the DB Connection Service is Initializing or Shutdown EN S9 Category Item Description Values Q Operation Operation status Operation status of the DB Connection Service Running Operation Mode 2 Information Runnin
16. Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur This instruction can be used only for the built in EtherNet IP port of an NJ series CPU Unit It is impossible to connect to a DB via an EtherNet IP Unit connected to an NJ series CPU Unit The DB Connection created by this instruction is closed in the following cases When a DB_Close or DB_ Shutdown instruction is executed When the operating mode of the Controller is changed from RUN mode to PROGRAM mode When the DB Connection Service is stopped A maximum of three DB Connections can be established at the same time When the DB Connection Service was started in Test Mode this instruction is completed normally without connecting to the DB actually When asame name DB Connection is already established the already established DB Connection is output to the DBConnection output variable An error occurs for this instruction in the following cases Error will be TRUE When the instruction w
17. DB mapping SQL type DB Map Variable Var_Insert can be used in DB_Insert Insert f gt INSERT DB Record instructions Use Var_Insert Structure data type for n F gt UPDATE Var_Update can be used in DB access ar_Update DB_Update Update DB Record instructions DB Map Variable gt SELECT Var_Select can be used in Var_Select DB_Select Retrieve DB Record instructions By executing a DB_CreateMapping Create DB Map instruction The DB mapping means to assign each member of a DB Map Variable to the corresponding column of a table in the connected DB You need to execute the DB mapping for each record processing for inserting updating and retrieving records You can map more than one DB Map Variable for a DB Connection The following table shows the operation of each record processing i e INSERT UPDATE and SELECT to be performed when you create a structure where not all but some of the columns are specified as members Record processing Operation Inserting records INSERT The record values are written to the specified columns of the DB NULL is entered in the unspecified columns You need to make a setting for allowing NULL in the DB Updating records UPDATE Values are updated only in the specified columns Values are not changed in the unspecified columns Retrieving records SELECT Values are retrieved only from the specified columns EN Additional Info
18. Operating DB_GetConnectionStatus_instance Error Error handler GetServiceStatus_OK FALSE A 68 NJ series Database Connection CPU Units User s Manual W527 Appendix A Structured Text ST Main Variables Name Data type Initial value Comment DB_GetConnectionStatus_instance DB _GetConnectionStatus Instance of DB_GetConnectionStatus instruction Trigger BOOL FALSE Variable used as a trigger for getting the status of the DB Connection LastTrigger BOOL FALSE Variable to retain the trigger status of the previous execution Operating BOOL FALSE The DB_GetConnectionStatus instruction is executed when this variable is TRUE OperatingStart BOOL FALSE The initialization processing is executed when this variable is TRUE MyStatus _sDBC_CONNECTION_STATUS This variable is assigned to the ConnectionStatus output variable from DB_GetConnectionStatus_instance Warning BOOL FALSE This variable changes to TRUE when the Spool usage has exceeded 80 suonon suj UO9 UUOD gq J W O 2 O O 5 5 Oo Q 5 A D snes uonoauuop ga 199 NJ series Database Connection CPU Units User s Manual W527 A 69 Appendix A Sample Programming Start the sequence when the variable Trigger changes to TRUE IF Trigger TRUE AND LastTrigger FALSE THEN OperatingStart TRUE Operating TRUE END_IF LastTrigger Trigger Sequence start processing IF
19. Phenomenon 2 After Execution of a DB_CreateMapping Instruction Execution Time of the First DB_Insert Instruction Got Longer Possible causes The following can be the causes 1 For the first DB_Insert instruction that is executed after execution of a DB_CreateMapping instruction the DB may require longer processing time than usual The following table gives the reference values for execution time of the first DB_Insert instruction that is executed after execution of a DB_CreateMapping instruction x Reference value for Ps DB type Instruction f i Measurement condition instruction execution time Oracle Database 11g DB_Insert 29 9ms When executing an INSERT operation for 100 column record SQL Server 2012 DB_Insert 31 3ms When executing an INSERT operation for 100 column record Percentage of task execution time 50 e Countermeasures 1 Measure the execution time of the DB Connection Instruction in reference to B 1 2 How to Measure Execution Time of DB Connection Instructions If the execution time of the DB Connection Instruction exceeds the acceptable range of the equipment take the following actions Execute a dummy DB_Insert instruction once after executing the DB_CreateMapping instruction as a preparation for starting the actual operation Phenomenon 3 When Communications or SD Memory Card Processing was Executed in the CPU Unit Execution Time of a DB Connection Instruction Got Longer
20. Regulations and Standards 22 on the above mentioned lists You will not use the Programs for and will not allow the Programs to be used for any purposes prohibited by United States law including without limitation for the development design manufacture or production of nuclear chemical or biological weapons of mass destruction EXPORT RESTRICTIONS You agree that U S export control laws and other applicable export and import laws govern your use of the programs including technical data additional information can be found on Oracle s Global Trade Compliance web site http www oracle com products export You agree that neither the programs nor any direct product thereof will be exported directly or indirectly in violation of these laws or will be used for any purpose prohibited by these laws including without limitation nuclear chemical or biological weapons proliferation Oracle Employees Under no circumstances are Oracle Employees authorized to download software for the purpose of distributing it to customers Oracle products are available to employees for internal use or demonstration purposes only In keeping with Oracle s trade compliance obligations under U S and applicable multilateral law failure to comply with this policy could result in disciplinary action up to and including termination Note You are bound by the Oracle Technology Network OTN License Agreement terms The OTN License Agreement terms a
21. Remarks Event name Too Many DB Connections Event code 5401 3007 hex Meaning The number of DB Connections that can be established at the same time is exceeded Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None a Cause and Assumed cause Correction Prevention correction The relevant instruction was Correct the user program so that Write the user program so that the executed when the maximum the number of established DB number of established DB number of DB Connections that Connections does not exceed the Connections does not exceed the can be established at the same maximum number of DB maximum number of DB time were already established Connections that can be Connections that can be established at the same time established at the same time Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified no
22. 7 37 Bee Guloouse qnol Z 2 suondnos q 10113 2 2 2 7 Troubleshooting 7 38 NJ series Database Connection CPU Units User s Manual W527 Appendix A DB Connection Instructions i cane A 1 DB Connection Instructions and Variables ccccceeceeeeeeeceeeeeeeeeeeeenees A 2 A 1 1 DB Connection Instruction Set c cccccesceeesesceeeeseeeeeesseaeesesseaees A 2 A 1 2 Variables Used in the DB Connection InstructionS c ce A 3 DB_Connect Establish DB Connection cccccceeeeeeeeeceeeeeeeeeeeesenaeeeeeeeeeeteeeas A 6 DB_Close Close DB Connection ccccccecceeecceeeeeeeeeeeeeeaeeeeeeeeeeesenaaeeeeeeeeeeeeeeas A 9 DB_CreateMapping Create DB Map cecceeeececeeeeeneeeeeeeneeeeeseaeaeeeeenaeeeersaeees A 11 DB_Insert Insert DB Record c cccceeceeeeeeeceeceeeeeeeeeeceeeaeeeeeeeeeeseeneneaeeeeeenenies A 14 DB_Update Update DB Record 0 eee eeeeeeeeeeeeneeeeeeeeeeeeeseaeeeeeeeneaeeeersaaeeeeeeaaes A 18 DB_ Select Retrieve DB Record ccccccecceeceeeeeeeeeeeeeneaeeeeeeeeeeesencaeeeeeeeeeeeeeaas A 34 DB_Delete Delete DB ReCOrd cccceceeeeeeeceeeceeeeeeeeeeceeeaeeeeeeeeseeeensaaeeseeeeetenies A 39 DB_ControlService Control DB Connection SENVICe eee eeeeee cere eeeteeeeeneeeeeeeeeeneeeseeeeteeeeeneeee A 54 DB_GeServiceStatus Get DB Connection Service Status eee eceeeeeereeeneeeeneeeteneereeeeees A 60 DB_GetConnectionStattus
23. Adding a DB Connection 1 Right click DB Connection Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Add DB Connection Settings DB Connection Settings from the Insert Menu ar DB Connection Settings sBulljes uoloeuu0D gq Z Z from the menu Or select A DB Connection is added You can add up to three DB Connections v Host Connection Settings v DB Connection fa DB Connection Service Settings y DB Connection Settings DBConnection01 Changing the DB Connection Name When a DB Connection is created the following default name is automatically given is a serial number from 01 sumes uoyo uuoy gd Z Z Z DBConnection To change the name right click the DB Connection in the Multiview Explorer and select Rename from the menu You can enter single byte alphanumeric characters and underscores _ Each DB Connection name can be up to 16 bytes Editing or Deleting the DB Connection Settings Right click the DB Connection in the Multiview Explorer and select Edit or Delete from the menu NJ series Database Connection CPU Units User s Manual W527 2 7 2 DB Connection Settings Connection Settings This section describes how to make a setting of each DB Connection and how to perform a communications test DB Connection Settings Double click each DB Connection that you added and make the settings in th
24. CONCAT LotNo UINT_TO_STRING LotNo AND FinishTime lt TO_TIMESTAMP DtToString MapVar_Select 0 FinishTime YYYY MM DD HH24 MI SS FF9 NJ series Database Connection CPU Units User s Manual W527 Appendix A A 51 suonon suj uonosuuon gq w W g D D D p10094 gq 1912 Appendix A OperatingStart_Delete FALSE END_IF Delete records from the table Production of the DB Connection MyDB1 Timeout is not monitored for the instruction execution IF Operating_Delete TRUE THEN Delete the records DB_Delete_instance Execute TRUE DBConnection MyDB1 TableName Production Where WhereCond_ Delete IF DB_Delete_instance Done TRUE THEN Operating_Delete FALSE Normal end Request_Delete FALSE END_IF IF DB_Delete_instance Error TRUE THEN Execute the error handler Program the error handler FaultHandler_Delete for the device FaultHandler_Delete Operating_Delete FALSE Request_Delete FALSE END_IF END_IF Close the DB Connection MyDB1 Start the sequence when the variable Trigger_Close changes to TRUE IF Trigger_Close TRUE AND LastTrigger_Close FALSE THEN OperatingStart_Close TRUE Operating_Close TRUE END_IF LastTrigger_Close Trigger_Close Sequence start processing IF OperatingStart_Close TRUE THEN Initialize the instance of the applicable DB Connection Instruction DB_Clos
25. Entire Agreement You agree that this agreement is the complete agreement for the programs and licenses and this agreement supersedes all prior or contemporaneous agreements or representations If any term of this agreement is found to be invalid or unenforceable the remaining provisions will remain effective Last updated 01 24 09 Should you have any questions concerning this License Agreement or if you desire to contact Oracle for any reason please write Oracle America Inc 500 Oracle Parkway Redwood City CA 94065 Oracle may contact you to ask if you had a satisfactory experience installing and using this OTN software download NJ series Database Connection CPU Units User s Manual W527 25 Unit Versions Unit Versions Unit Versions A unit version has been introduced to manage CPU Units in the NJ Series according to differences in functionality accompanying Unit upgrades f Notation of Unit Versions on Products The unit version is given on the ID information label of the products for which unit versions are managed as shown below Example for NJ series NJ501 CPU Unit ID information label Unit model Unit version m m m m m m pm m 1 NJ501 1520 1 Ver 1 J m m Smee eee ha x PORT1 MAC ADDRESS PORT2 MAC ADDRESS K on eoa ona e
26. Get DB Connection Status 20 0 ccc ceccececscseecessceeeeeeeseeeeeeeseneeeeeenneaes A 65 DB_ControlSpool Resend Clear Spod Datta ccceececceceeseseeceeseneeeeseceeeeeeeseneeeeeesnaes A 71 DB_PutLog Record Operation Log cececceeeeseeeeeeeeeeeeeeseneeeeeeeneaeeeeeseaeeeessaeees A 78 DB_Shutdown Shutdown DB Connection Sevice eee eeeeeeceeeeeeeteeeeneeeeneeeeeneeeseieeeenneereneeee A 84 NJ series Database Connection CPU Units User s Manual W527 A 1 Appendix A A 1 DB Connection Instructions and Variables A 1 1 DB Connection Instruction Set This section gives a list of DB Connection Instructions Instruction Name Page DB_Connect Establish DB Connection A 6 DB_ Close Close DB Connection A 9 DB_CreateMapping Create DB Map A 11 DB_Insert Insert DB Record A 14 DB_Update Update DB Record A 18 DB_Select Retrieve DB Record A 34 DB_Delete Delete DB Record A 39 DB_ControlService Control DB Connection Service A 54 DB_GetServiceStatus Get DB Connection Service Status A 60 DB_GetConnectionStatus Get DB Connection Status A 65 DB_ControlSpool Resend Clear Spool Data A 71 DB_PutLog Record Operation Log A 78 DB_Shutdown Shutdown DB Connection Service A 84 NJ series Database Connection CPU Units User s Manual W527 Appendix A A 1 2 Variables Used in the DB Connection Instructions This section describes the details of the variables used in the DB Connection Instruct
27. OperatingStart TRUE THEN Initialize the instruction instance DB_GetConnectionStatus_instance Execute FALSE OperatingStart FALSE END_IF IF Operating TRUE THEN Get the status of the DB Connection DB_GetConnectionStatus_instance Execute TRUE DBConnectionName _ MyDatabase1 ConnectionStatus gt MyStatus IF DB_GetConnectionStatus_instance Done TRUE THEN Normal end processing Change the variable Warning to TRUE when the Spool usage has exceeded 80 IF MyStatus SpoolUsageRate gt SINT 80 THEN Warning TRUE END_IF Operating FALSE END_IF IF DB_GetConnectionStatus_instance Error TRUE THEN Error handler Operating FALSE END_IF END_IF A 70 NJ series Database Connection CPU Units User s Manual W527 Appendix A DB_ControlSpool Resencd Clear Spool Data The DB_ControlSpool instruction resends or clears the SQL statements spooled by DB_Insert Insert DB Record and DB_Update Update DB Record instructions Instruction Name FB FUN Graphic expression ST expression DB_ControlSpool Resend Clear FB DB_ControlSpool_instance DB_ControlSpool_instance Spool Data Execute DBConnection DB_ControlSpool Cmad Done Busy Error Done ErrorlD Execute DBConnection Busy Cmd Error ErrorlD Note The DB_ControlSpool_instance is an instance of DB_ControlSpool instruction which is declared as a variable
28. S 5 16 The numbers in the following table are corresponding to the numbers in the above figure Power interruption timing during execution of a DB Connection Instruction Value of SendStatus output variable Action 1 Executed When instruction execution is started Until the DB Connection Service reads the present value of the DB Map Variable after Execute of the DB Connection Instruction changed from FALSE to TRUE 2 Reading DB Map Variable Until the DB Connection Service sends the SQL statement to the DB after the service started reading the present value of the DB Map Variable 3 Sending SQL statement Until the transmission is completed since immediately before the DB Connection Service sends the SQL statement to the DB 4 Response from DB Until the response from DB is received after the SQL statement was sent to DB 5 Spooling the data when failure occurred While the SQL statement is being spooled because a failure has occurred when spooling is enabled 5 Spooling the data when Instruction Execution Timeout occurred While the SQL statement is being spooled because an Instruction Execution Timeout has occurred when spooling is enabled _DBC_SEND_ SENDING Sending SQL statement Resend by user program 6 Normal response received After normal response is received from the DB _DBC_SEND_COMPLETE SQL statement transmission complete
29. SQL statement transmission completed Variable Settings Set the Retain attribute of the input parameter DB Map Variable of the MapVar input variable to Retained Set the Retain attribute of the output parameter of the Busy output variable to Retained Set the Retain attribute of the output parameter of the SendStatus output variable to Retained NJ series Database Connection CPU Units User s Manual W527 5 15 5 Other Functions i Necessary Actions against Power Interruption You need to take an action against power interruption according to when power interruption occurs This section describes the necessary actions using the following figure CPU Unit Server DB Connection Service FN Program a DB Connection Instruction 3 Sending SQL statement EtherNet IP Relational Database DB_Insert 1 Executed Done When spooling is enabled 5 Spooling the data when failure occurred Execute 2 Reading DB Map DBConnection Busy Variable 5 Spooling the data when Instruction Execution MapVar ie Timeout occurred 4 Response from DB TimeOut ErrorlD 7 6 Normal response received SendStatus 6 Data spooled EM Area non volatile memory Spool memory INSERT INSERT INSERT a
30. fe fa n D D O 0 Create a structure data type for DB access The structure members must satisfy the following conditions Member names are the same as corresponding column name of the table to access Members data types match the data type of corresponding column of the table to access Refer to 3 3 Creating a DB Map Variable Create a variable called DB Map Variable using the structure data type created in STEP 4 STEP 5 Creating a Variable Using above Structure Refer to 3 4 Specifying the Table and Apply the Mapping and 3 5 Programming and Transfer STEP 6 Programming using DB Connection Instructions 1 Write a DB_ControlService Control DB Connection Service instruction This instruction is not required if you set the DB Connection Service to auto start in the DB Connection Settings 2 Write a DB_Connect Establish DB Connection instruction 3 Write a DB_CreateMapping Create DB Map instruction The DB Map Variable is mapped with the columns of the table to access and registered as a variable subject to the record processing 4 Write DB_Insert Insert DB Record DB Update Update DB Record DB_ Select Retrieve DB Record and other instructions STEP 7 Transferring a Project to the CPU Unit Belerlog gt Programming and Transfer NJ series Database Connection CPU Units User s Manual W527 1 9 1 Introduction to the DB Connec
31. status after the power supply to the CPU Unit was turned ON Idle The DB Connection Service is not The DB Connection settings can be changed SOINOS UOIN8UUOD Gq ey JO SNIS UuOITesJEdO E 7 NJ series Database Connection CPU Units User s Manual W527 4 7 4 Basic Operations and Status Check Status Description Remarks running without having any error The DB Connection Instructions cannot be executed Running Operating Mode The DB Connection Service is The DB Connection settings cannot be running in Operation Mode changed The DB Connection Instructions can be executed Running Test Mode The DB Connection Service is The DB Connection settings cannot be running in Test Mode changed The DB Connection Instructions can be executed but SQL statements are not sent to the DB Error The DB Connection Service cannot The status changes to Error in the following run due to an error case When the DB Connection Service settings are invalid Shutdown The DB Connection Service is The status changes to Shutdown when the DB already shut down Connection Service is shut down by an instruction or Sysmac Studio operation After the shutdown processing of the DB Connection Service is completed you can safely turn OFF the power supply to the CPU Unit You cannot start the DB Connection Service again until you execute the Reset Controller operation or cycle the power supply to the CPU Unit
32. sufficient available space The SD Memory Card is If none of the above causes Do not remove the SD Memory damaged applies replace the SD Memory Card or turn OFF the power supply Card while the SD BUSY indicator is lit Do not remove the SD Memory Card while the SD PWR indicator is lit Replace the SD Memory Card periodically according to the write life of the SD Memory Card Attached Attached information 1 Error Details information 0001 hex An SD Memory Card is not inserted 0002 hex The SD Memory Card is damaged the format of the SD Memory Card is not correct or the SD Memory Card is not the correct type of card 0003 hex The SD Memory Card is write protected 0302 hex The capacity of the SD Memory Card is insufficient the SD Memory Card is damaged or failed to save a file to the SD Memory Card due to other factors Precautions You can change the error level to the observation Remarks 7 18 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name DB Connection Setting Error Event code 3530 0000 hex Meaning The DB Connection settings are not correct Source PLC Function Module Source details DB Connection Detection At download Service timing power ON or Controller reset Error attributes Level Minor fault Recovery Automatic Log category System recovery Effects User program Continues Operation The DB Connection Service cann
33. 0 ccc ceecceeecee cece eeeeceeeaeeeeeeeeeeeeeneneeeeeeeeess A 6 DB_Close Close DB Connection cccccceeceeeceeceeeeeeeeeeeeeeeaeeeeeeeeeeeseneeeaeeeeeeeetees A 9 DB_CreateMapping Create DB Map eceeeceeeeseeceeeeeneeeeeeeneeeeeeeneaeeeeesaeeeeeeaas A 11 DB_Insert Insert DB Record 2 02 2 ceceeeeeceeeeeeeeeeeenee cnet eres seeccaeaeeeeeeeeeetensneeeeeeeetees A 14 DB_Update Update DB Record 0 eeecceeeeeeneeeeeeseeeeeeeneeeeeeeeeeeeteeneeeeeeesaeeeeeenaes A 18 DB_Select Retrieve DB Record c cccceceeeceeeceeeeeeeeeeeeeeeeeaeaeeeeeeeeseeeenaeeeeeeeess A 34 DB_Delete Delete DB ReCord ccccccceceeeeeeteeeeeeeeeeeeeececeeeaeeeeeeeeteeceseaeeeeeeeenees A 39 DB_ControlService Control DB Connection Service aca sone exacts eects a eee eases eee evoserects A 54 DB_GetServiceStatus Get DB Connection Service Status ccccsesseeeeeeseeeeeeeeeeeeeeseteeeeees A 60 DB_GetConnectionStatus Get DB Connection Status cccceccceceeeseeeeeeeseeeeeeeseeeeeesseneeeeees A 65 NJ series Database Connection CPU Units User s Manual W527 CONTENTS DB_ControlSpool Resend Clear Spool Data eccsccceeeseeeceeeeeneeeeeseneeeeeseeneeeessneees A 71 DB_PutLog Record Operation LOQ ccceecceeeseneeeeeeeeeeeeeeeeeeeeeeeseeeeeeneaeeeenseaeees A 78 DB Shutdown Shutdown DB Connection Service cccecccceeseeeceeeceneceeeseeeaeeesesteeeessnaeees A 84 Appendix IB c
34. 3 6 1 Design PRaSe esis iene lia ied wie iinet AATE 3 20 3 6 2 Startup Phase araiarraren ian da 3 20 3 6 3 Operation PHaSe ccececce cece ceeneeceeeee cee eeeaaeseeeeeceeeesaeseeeeeeeseeeee 3 21 4 Basic Operations and Status Check ccceeeeeeeeeeeee cette etter eeteeeeeeaeeeeeeeeeeeees 4 1 4 1 Run Mode of DB Connection Service and Start Stop Procedures 4 2 4 1 1 Run Mode of the DB Connection Service 4 2 4 1 2 How to Start Stop the DB Connection Service ccceeeeeees 4 2 4 1 3 DB Connection Service is Stopped or Cannot be Started 4 4 4 1 4 Changing the Run Mode of the DB Connection Service 45 4 5 4 2 Establishing Closing a DB Connection ccccccccceeeeeceeeeeceeeeeeseneceeeeessaeeeeeseneeeeees 4 6 4 3 Checking the Status of DB Connection Service and each DB Connection 0 4 7 4 3 1 Operation Status of the DB Connection Service cccceeeerees 4 7 4 3 2 Checking the Status of the DB Connection Service 00 4 8 NJ series Database Connection CPU Units User s Manual W527 7 CONTENTS 4 3 3 Connection Status of each DB Connection ccceeeeeeeeeeeees 4 11 4 3 4 Checking the Status of each DB Connection cccseeeeeseees 4 12 5 HOMOn PUMGHONS s ssccias oceans E tetera E teins veulieceeilarss ook 5 1 5 1 Spool FUNGUO Masira Aan avis Weenies LELE EA L E aia EEEE e adi 5 2 5 1 1 OVEIVICW e iea e
35. 3 Programming the DB Connection Function 3 22 NJ series Database Connection CPU Units User s Manual W527 Basic Operations and Status Check Ea This section describes how to start and stop the DB Connection Service how to establish and close a DB Connection and how to check the status of the DB Connection Service and each DB Connection 4 1 Run Mode of DB Connection Service and Start Stop Procedures 4 2 4 1 1 Run Mode of the DB Connection ServiCe ccceceesseeeeesesteeeeeees 4 2 4 1 2 How to Start Stop the DB Connection Service ccccceeeeeees 4 2 4 1 3 DB Connection Service is Stopped or Cannot be Started 4 4 4 1 4 Changing the Run Mode of the DB Connection Service 4 5 4 2 Establishing Closing a DB COMMCCHON ccccccccccsscssssseeseeceeesessseeseeeeeessesseseaaeeeeees 4 6 4 3 Checking the Status of DB Connection Service and each DB Connection eee 4 7 4 3 1 Operation Status of the DB Connection Service cc cccceeeeees 4 7 4 3 2 Checking the Status of the DB Connection Service 0ce 4 8 4 3 3 Connection Status of each DB Connection cccccceesseeeeeeenees 4 11 4 3 4 Checking the Status of each DB Connection ceceeeeeeeenees 4 12 NJ series Database Connection CPU Units User s Manual W527 4 1 4 Basic Operations and Status Check 4 1 Run Mode of DB Connection Service and Start Stop Procedures Thi
36. CPU Units User s Manual W527 6 5 6 How to Use Operation Logs 6 6 The following is the format of records Each record is expressed in one line and composed of multiple parameters The parameters are separated from each other by a tab Serial number lt tab gt Date lt tab gt Time lt tab gt Millisecond lt tab gt Category lt tab gt Log code lt tab gt Log name lt tab gt Result lt tab gt DB Connection name lt tab gt Serial I D lt tab gt Details lt CR gt lt LF gt Parameter Size Description Serial 1 to 5 bytes 0 to 65535 number When exceeding 65535 this value returns to 0 The serial number is given across multiple files Even if a new file is created the serial number is not reset to 0 Date 10 bytes Fixed Displays year month and date when the log was recorded YYYY MM DD Example 2012 07 23 Time 8 bytes Fixed Displays hours minutes and seconds when the log was recorded n hh mm ss Example 15 33 45 Millisecond 3 bytes Fixed Displays 3 digit decimal integer 000 to 999 that shows millisecond of the time when the log was recorded Example 10 ms 010 623 ms 623 Category 16 bytes max Variable Displays the category Log code 4 bytes Fixed Displays a 4 digit decimal code that is a unique identification code in the category Log name 32 bytes max Variable Displays a name that shows the contents of the log Result 6 bytes Fixed D
37. Connection Service is started Error attributes Level Information Recovery Log category System Effects User program Continues Operation Not affected System defined Variable Data type Name variables _DBC_Status _sDBC_STATUS DB Connection Service Status Cause and Assumed cause Correction Prevention correction The DB Connection Service was successfully started Attached Attached information 1 Start reason information 01 hex Execution of a DB_ControlService instruction or operation from Sysmac Studio 02 hex Controller s operating mode change from PROGRAM to RUN mode Precautions None Remarks Event name DB Connection Service Stopped Event code 95310000 hex Meaning The DB Connection Service was stopped Source PLC Function Module Source details DB Connection Detection When the DB Service timing Connection Service is stopped Error attributes Level Information Recovery Log category System Effects User program Continues Operation Not affected System defined Variable Data type Name variables _DBC_Status _sDBC_STATUS DB Connection Service Status Cause and Assumed cause Correction Prevention correction The DB Connection Service was stopped Attached Attached information 1 Stop reason information 01 hex Execution of a DB_ControlService instruction or operation from Sysmac Studio 02 hex Controller s operating mode change from RUN to PROGRAM mode 03 hex Execution of Synchronization download Clear All Memory or
38. Connection Service Item Description CPU Unit model Special models The other functions are same as the NJ501 1100 CPU Units e NJ501 1520 64 axis type NJ501 1420 32 axis type NJ501 1320 16 axis type Supported DB Microsoft Corporation SQL Server 2008 2008 R2 2012 Oracle Corporation Oracle Database 10g 11g Number of DB Connections Number of databases that can be connected at the same time 3 connections max Instruction Supported operations The following operations can be performed by executing DB Connection Instructions in the NJ series CPU Units Inserting records INSERT Updating records UPDATE Retrieving records SELECT and Deleting records DELETE Number of columns in an INSERT operation SQL Server 1 024 columns max Oracle 1 000 columns max Number of columns in an UPDATE operation SQL Server 1 024 columns max Oracle 1 000 columns max Number of columns in a SELECT SQL Server 1 024 columns max operation Oracle 1 000 columns max Number of records in the output of 65 535 elements max 4 MB max a SELECT operation Number of DB Map Variables for which a mapping can be created 15 variables max Even if the number of DB Map Variables has not reached the upper limit the total number of members of structures used as data type of DB Map Variables is 10 000 members max Run mode of the DB Connection Service Operation Mod
39. DB Map Variable specified in the MapVar in out variable and 0 is output to both the RecCnt and SelectedCnt output variables Even if the specified number of bytes in STRING data is shorter than the table data this instruction is normally J W QO O 3 5 oO QO O 5 gt an 2 c Q O 3 na o ended D Example When 12 characters are contained in a table column and data type of the corresponding member of the DB Map Variable is STRING 11 this instruction can retrieve only up to 11 characters but willbe normally ended E When the error code is 300B hex SQL Execution Error you can get the detailed information of the SQL g Execution Error by executing a DB_GetConnectionStatus instruction T The measurement error of timeout is 10 ms as a guide However the measurement error may vary if enough execution time cannot be secured for the system service w When two or more DB Connection Instructions are executed for a DB Connection at the same time the DB D Connection Service executes the instructions one by one The measurement of timeout for the second and 3 later instructions is started when the instruction is executed by the DB Connection Service not when the Execute input variable is changed to TRUE Therefore the time from when the Execute input variable is changed to TRUE to when the timeout occurs for the instruction is longer than the time set for the timeout An error occurs for this instruction
40. Data type name VARCHARA2 256 VARCHARA2 256 NUMBER 5 NUMBER 5 NUMBER 5 amp Data type name Enter the following on Microsoft Excel Data type name gt Br zaua orgii z ee ProductionT able ProductName LotNo TotalCount SuccessCount FailedCount sse00y gq 10 d L gq aunjoms E 942919 0 MOH E Z E LotNo Total Count STRING 256 Member name SuccessCount m FailedCount STRING 256 NJ series Database Connection CPU Units User s Manual W527 3 7 3 Programming the DB Connection Function Lal Precautions for Correct Use You cannot paste the data type onto the Structure Data Type Editor in the following cases eWhen a structure member is selected on the editor eWhen nothing is selected on the editor When executing the Paste operation on the Structure Data Type Editor please select a structure data type not a member EN Additional Information You can reuse a table definition data of your DB development tool to create a structure data type for DB access Use the following procedure 1 Copy the column name and data type on the table definition data of the DB development tool 2 Create a Column Name column and a Data Type column on Microsoft Excel or other spreadsheet software 3 Change the data type of each column to the corresponding data type for variables of NJ series CPU Units 4 Insert a line above the data of column nam
41. Database Connection CPU Units User s Manual W527 Appendix A Common Variables Used in NJ series Instructions Input variable Meaning Data type Description Execute Execute BOOL The instruction is executed when Execute changes to TRUE Output variable Meaning Data type Description Done Done BOOL Shows whether the instruction is normally completed TRUE Normally completed FALSE Terminated due to an error Being executed Execution conditions not satisfied Busy Executing BOOL Shows whether the instruction is being executed TRUE Being executed FALSE Not being executed Error Error BOOL Shows whether the instruction is terminated due to an error TRUE Terminated due to an error FALSE Normally ended Being executed Execution conditions not satisfied ErrorlD Error Code WORD Contains the error code when the instruction is terminated due to an error WORD 16 0 indicates normal execution System defined Variables Related to DB Connection Service Data type Description DB Connection Service _sDBC_ STATUS Status Refer to 3 5 4 System defined Variables for details of the system defined variables P 0 u Q 5 5 D Q fa 3 D pa O ot fe 5 D o a lt A Z D o D 7 System defined variable that shows the status of the DB Connection Service _DBC_Status SUOI ONJISU UOIJXSUUOD gq 3y UI pesfp SOLLA Z L Y NJ series Da
42. Database Connection CPU Units User s Manual W527 Appendix A Sample Programming Record the log code 100 log name Production Order and log message Production Start RecipeCode 12345678 into the Execution Log Check the completion of the DB_PutLog instruction DB_PutLog_instance Done OperatingEnd DB_PutLog_nstance Error Accept the trigger RS_instance Operating Trigger RS y Set Q1 OperatingEnd Reset1 Create the log message Operating 1 Msg CONCAT Production Start RecipeCode UDINT_TO_STRING RecipeCode Record the log message into the Execution Log DB_PutLog_instance Operating DB PutLog Execute Done _eDBC_LOGTYPE _DBC_LOGTYPE_EXECUTION LogType Busy O Ww O O 5 5 oO QO O 5 5 D o c QO O 5 D 100 LogCode Error Production Order LogName ErrorlD Msg LogMsg When the instruction is normally completed change the variable PutLog_OK to TRUE Operating DB_PutLog_instance Done _ When the instruction is terminated due to an error change the variable PutLog_OK to FALSE Normal end processing PutLog_OK TRUE Operating DB_PutLog_instance Error Error handler ____ PutLog_OK FALSE 607 uones8do piooey Bona gq NJ series Database Connection CPU Units User s Manual W527 A 81 Appendix A Structured Text ST Main Variable
43. E E AAE E A 1 2 1 1 2 Features s ia a na e aa e a 1 2 1 2 DB Connection Service Specifications and System 1 4 1 2 1 DB Connection Service Specifications ccccceeceeeeeeeeeseeeeeneeeees 1 4 1 2 2 DB Connection System ccccccsceeeceeeeeeeeeaeeeeeeeeeeeeeaeeteeeeeeeeeeaas 1 6 1 3 Operation Flow of the DB Connection Service eee eeceeeeeeeneeeeeeeneeeeteees 1 8 6 NJ series Database Connection CPU Units User s Manual W527 CONTENTS 2 DB Connection Settings scence teeeen cies ors sores Senet ealans eta ice enous busines alee 2 1 2 1 Starting Sysmac Studio and Creating a New Project 2 2 2 1 1 Starting Sysmac Studio c ce eeseeeseeeeeeeeeeeeeeeeeeseeeeeseeeeeaeeeeeeeeeeas 2 2 2 1 2 Creating a New Project ccccccscceseeeceeeeeeeaeeeeseeseeeeeseaeeeeeaeeeneneeeaas 2 2 2 1 3 Setting the Built in EtherNet IP Port s es 2 3 2 2 DB Connection Settings sare aaa ai es 2 4 2 2 1 DB Connection Service Settings ccccceeeeseeeeeeeeseeeeeeeneeeeeeeees 2 4 2 2 2 DB Connection Settings c cccccceeeseeceeeeseeeeeeeeeseeeeeeseeeeeeeeeeeees 2 7 3 Programming the DB Connection FUNCTION seeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeees 3 1 3 1 DB Access ProCe QUre isiin niie eea ain in Enitan it 3 2 3 2 Creating a Structure Data Type eee cee eeeceeeeeeeneeeeeenneeeeeetnaeeeeeseeeeeeeeneeeeey 3 3 3 2 1 OVEIVICW stead ean ieee laa feeds Aan ies cl S ai 3 3 3 2 2 Specifications of St
44. Excel or a text editor Use the following procedure You use the FTP Server function of the built in EtherNet IP port 1 Double click Built in EtherNet IP Port Settings under Configurations and Setup Controller Setup in the Multiview Explorer and set FTP server to Use in the FTP Settings 2 Log into the CPU Unit using the FTP client software 3 Transfer Operation Log files You can transfer more than one log file by using a wildcard in the Mget command Example mget DB_ExecutionLog_ log 4 Disconnect the FTP client software from the CPU Unit 5 Open the transferred Operation Log files on Microsoft Excel or a text editor to check the contents NJ series Database Connection CPU Units User s Manual W527 Troubleshooting n This section describes the error confirmation methods and corrections for errors that can occur in the DB Connection Service 7 1 Ovemiew OF EO aaan A AE a a Aae E AONAR A RANE 7 2 7 1 1 How to Check for Errors cccccccccccccecsesseecesceececsesteeeeseceesesesesseaeeas 7 3 7 1 2 Errors Related to the DB Connection Service ccecceceeeteeeeeeees 7 5 7 2 AREON eE EIONiLAT PAP EE A sae EEA EE E E A E 7 7 7 2 1 ala e EE AE E TEE OE AA E E EE 7 7 7 2 2 Error Descniph ns ss eraron TE EA e RE TEE 7 15 NJ series Database Connection CPU Units User s Manual W527 7 1 7 Troubleshooting 7 1 Overview of Errors 7 2 You manage all of the errors that occur on the NJ series Controller as eve
45. Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing e When you execute this instruction to resend the Spool data this instruction just starts the Spool data resending processing When the value of the Done output variable changes to TRUE the resending processing of the SQL statements stored in the Spool memory has not been completed Confirm the completion of resending processing by reading the number of Spool data using the DB_GetConnectionStatus instruction When the Spool function is not enabled this instruction will be completed normally without executing the resend or clear processing of the SQL statements stored in the Spool memory The Clear Spool Data operation can be executed even when the DB Connection Service is not running Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur A 72 NJ series Database Connection CPU Units User s Manual W527 Appendix A An error occurs for this instruction in the following cases Error will be TRUE When the Resend Spool Data operation was executed by this instruction when the DB Connection Service was not running When the instruction was executed while the initialization pro
46. Low Voltage Directive i Concepts EMC Directive OMRON devices that comply with EC Directives also conform to the related EMC standards so that they can be more easily built into other devices or the overall machine The actual products have been checked for conformity to EMC standards Whether the products conform to the standards in the system used by the customer however must be checked by the customer EMC related performance of the OMRON devices that comply with EC Directives will vary depending on the configuration wiring and other conditions of the equipment or control panel on which the OMRON devices are installed The customer must therefore perform the final check to confirm that devices and the overall machine conform to EMC standards Applicable EMC Electromagnetic Compatibility standards are as follows EMS Electromagnetic Susceptibility EN 61131 2 and EN 61000 6 2 EMI Electromagnetic Interference EN 61131 2 and EN 61000 6 4 Radiated emission 10 m regulations Low Voltage Directive Always ensure that devices operating at voltages of 50 to 1 000 VAC and 75 to 1 500 VDC meet the required safety standards The applicable directive is EN 61131 2 Conformance to EC Directives The NJ series Controllers comply with EC Directives To ensure that the machine or device in which the NJ series Controller is used complies with EC Directives the Controller must be installed as follows e The NJ series Controller must
47. Make a setting for the entire DB Connection Service and each DB Connection Also perform a communications test between Sysmac Studio and the DB as necessary 7 Setting of the entire DB Connection Service Double click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and set the following in the Service Settings Service Start Execution Log Debug Log and SQL Execution Failure Log settings 2 Setting of each DB Connection Right click DB Connection Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and add up to three DB Connections Then set the following for each DB Connection Database type Oracle or SQL Server IP address IP address of the server Database name Database name in the server User name password etc Spool settings 3 Communications test from Sysmac Studio to the DB only when necessary Double click a DB Connection under Configurations and Setup Host Connection Settings DB Connection DB Connection Settings and click the Communications Test Button under the DB Communications Test in the Connection Settings 1 8 NJ series Database Connection CPU Units User s Manual W527 1 Introduction to the DB Connection Service STEP 4 Creating a Structure for DB Access neier t ae Greatngia Structure Data Type y JO MO 4 UOeIdO J iB O e 5 5 D
48. MyStatus _sDBC_CONNECTION_STATUS This variable is assigned to the 3 ConnectionStatus output variable 2 from S o v Z o Warning BOOL FALSE This variable changes to TRUE when the Spool usage has exceeded 80 GetConnectionStatus_OK BOOL FALSE This variable changes to TRUE when the DB_GetConnectionStatus instruction is completed normally snes uonoauuop gq 105 NJ series Database Connection CPU Units User s Manual W527 A 67 Appendix A Sample Programming Change the variable Warning to TRUE when the Spool usage of the DB Connection named MyDatabase1 has exceeded 80 Check the completion of the DB_GetConnectionStatus instruction DB_GetConnectionStatus_instance Done OperatingEnd DB_GetConnectionStatus_instance Error Accept the trigger RS_instance Trigger t Operating OperatingEnd Get the status of the DB Connection DB_GetConnectionStatus_instance Operating DB_GetConnectionStatus Execute Done MyDatabase1 DBConnectionName Busy Error ErrorID ConnectionStatus MyStatus When the instruction is normally completed change the value of the variable Warning to TRUE if the Spool usage has exceeded 80 Operating DB_GetConnectionStatus_instance Done m Warning DINT 80 GetConnectionStatus_OK MyStatus SpoolUsageRate When the instruction is terminated due to an error change the variable Warning to FALSE
49. Not lit Not lit Power Supply Error Not possible Lit Not lit Not lit CPU Unit Reset Refer to the NU series Troubleshooting N Lit Flashing Lit Incorrect Power Supply Unit Manual Gat No W503 pare Connected T Lit Not lit Lit CPU Unit Watchdog Timer Error Lit Not lit Lit Major fault level Possible 5 Lit Lit Flashing Partial fault level Connect Sysmac Studio or an Q D Lit Lit Flashing Minor fault level Be eile Phang Check the calseiot Q Lit Lit Not lit Gbsenaton and correction for me error in the S troubleshooting functions of Sysmac Studio or the Troubleshooter of the ay NS series PT s Lit Lit Not lit Normal operation in RUN mode Lit Not lit Not lit Normal operation in PROGRAM i mode Lit Flashing Not lit Normal operation in startup state 1_ If you can go online with the CPU Unit from Sysmac Studio with a direct USB connection the CPU Unit is in PROGRAM mode If you cannot go online the CPU Unit is being reset 2 If you can go online with the CPU Unit from Sysmac Studio with a direct USB connection a major fault level error has occurred If you cannot go online a watchdog timer error has occurred in the CPU Unit 3 If you cannot go online with the CPU Unit from Sysmac Studio it is also possible that the USB cable is faulty or that the network type on Sysmac Studio is not set for a direct USB connection Refer to the NJ series Troubleshooting Manual Cat No W503 if you cannot go online wi
50. Omron before shipment Omron Companies shall not be liable for the suitability or unsuitability or the results from the use of Products in combination with any electrical or electronic components circuits system assemblies or any other materials or substances or environments Any advice recommendations or information given orally or in writing are not to be construed as an amendment or addition to the above warranty See http www omron com global or contact your Omron representative for published information NJ series Database Connection CPU Units User s Manual W527 11 Terms and Conditions Agreement f Limitation on Liability Etc OMRON COMPANIES SHALL NOT BE LIABLE FOR SPECIAL INDIRECT INCIDENTAL OR CONSEQUENTIAL DAMAGES LOSS OF PROFITS OR PRODUCTION OR COMMERCIAL LOSS IN ANY WAY CONNECTED WITH THE PRODUCTS WHETHER SUCH CLAIM IS BASED IN CONTRACT WARRANTY NEGLIGENCE OR STRICT LIABILITY Further in no event shall liability of Omron Companies exceed the individual price of the Product on which liability is asserted Application Considerations i Suitability of Use Omron Companies shall not be responsible for conformity with any standards codes or regulations which apply to the combination of the Product in the Buyer s application or use of the Product At Buyer s request Omron will provide applicable third party certification documents identifying ratings and limitations of use which apply to the Product This info
51. Operating TRUE THEN Get the status of the DB Connection Service DB_GetServiceStatus_instance Execute TRUE ServiceStatus gt MyStatus IF DB_GetServiceStatus_instance Done TRUE THEN Normal end processing Change the variable Warning to TRUE when the number of error executions is 100 or greater IF MyStatus FailedCnt gt DINT 100 THEN Warning TRUE END_IF Operating FALSE END_IF IF DB_GetServiceStatus_instance Error TRUE THEN Error handler Operating FALSE END_IF END_IF A 64 NJ series Database Connection CPU Units User s Manual W527 Appendix A DB_GetConnectionStaius Get DB Connection Stale The DB_GetConnectionStatus instruction gets the status of a DB Connection Instruction Name FB FUN Graphic expression ST expression DB_GetConnection Get DB FB i DB_GetConnectionStatus_i f DB_GetConnectionStatus_instance Status Connection nstance Execute Status DB_GetConnectionStatus DBConnectionName Done Busy Error ErrorlD Done Execute ConnectionStatus DBConnectionName Busy Error ErrorlD ConnectionStatus iw W Note The DB_GetConnectionStatus_instance is an instance of DB_GetConnectionStatus instruction which is declaredas O A fa a variable Q O Variables 5 Input Variabl Ai nput Variables z K aaa le Name Meaning Data type Valid range Unit Default Descripti
52. Operating_Connect DB_Connect_instance Error FaultHandler_Connect EN FaultHandler_Connect DB_CreateMapping_Insert_instance Error DB_CreateMapping_Update_instance Error Insert production data to the DB Connection MyDB1 when the variable Trigger_Insert changes to TRUE Check the completion of the DB_Insert instruction DB_Insert_instance Done OperatingEnd_Insert li DB_Insert_instance Error l Accept the trigger for inserting DB records RS_Insert_instance Trigger_Insert Operating_Insert OperatingEnd_Insert a Create production data to insert Operating_Insert MapVar_Insert Name Name MapVar_Insert LotNo UINT_TO_STRING LotNo yy MapVar_Insert Status Busy MapVar_Insert ProductionDate DT_TO_DATE GetTime NJ series Database Connection CPU Units User s Manual W527 A 25 J W QO O 3 5 oO QO O 5 gt an 2 c QO O 3 na puodey ga aw pdn spd ga Appendix A Insert production data to the DB Connection MyDB1 Set the timeout for instruction execution to 200 ms DB_Insert_instance Operating_Insert DB_ Insert Execute Done MyDB1 DBConnection Busy MapVar_Insert MapVar Error T 200ms TimeOut ErrorlD SendStatus When the instruction is terminated due to an error execute the error handler for the device FaultHandler_Insert Program the FaultHandle
53. Restore operation 04 hex A major fault level Controller error Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 21 Be Guloouse qnol 2 7 suondnos q 10113 2 2 2 7 Troubleshooting Event name DB Connection Service Shutdown Event code 9532 0000 hex Meaning The DB Connection Service was shut down Source PLC Function Module Source details DB Connection Detection When the DB Service timing Connection Service is shut down Error attributes Level Information Recovery Log category System Effects User program Continues Operation Not affected System defined Variable Data type Name variables _DBC_Status _sDBC_STATUS DB Connection Service Status Cause and Assumed cause Correction Prevention correction The DB Connection service was shut down Attached Attached information 1 Shutdown reason information 01 hex Execution of a DB_Shutdown instruction or operation from Sysmac Studio Precautions None Remarks 7 22 NJ series Database Connection CPU Units User s Manual W527 fi Errors Related to DB Connection Instructions 7 Troubleshooting Event name DB Connection Service Not Started Event code 5401 3000 hex Meaning The DB Connection Service has not been started Source PLC Function Module Source details Instruction Detection At instruction timing execution Error
54. Service Setting of Sysmac Studio This log is saved as SQL Execution Failure Log files on the SD Memory Card mounted in the CPU Unit When no SD Memory Card is mounted in the CPU Unit you cannot record the SQL Execution Failure Log You can check the contents of this log in the SQL Execution Failure Log Tab Page of the Operation Log Window in Sysmac Studio Application Procedure Use the SQL Execution Failure Log according to the following procedure Step Reference 1 Set the SQL Execution Failure Log Refer to 6 4 3 Setting the SQL Execution Failure Log 1 2 Check the SQL Execution Failure Log Refer to 6 6 Checking the Operation Logs Setting the SQL Execution Failure Log Double click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer Then set the following in the Service Setting Item Description Values SQL execution failure Set whether to record the SQL Execution Failure Log Record log Do not record Default Number of files Set the maximum number of files of the SQL Execution Failure 2 to 100 files Log Default 50 When the maximum number of files is reached the oldest file is deleted and a new file is created File size Set the maximum file size 1 to 100 MB When the maximum file size is exceeded or when the number of Default 10 MB records exceeds 65 536 records in a file a new file is created
55. TABLE_Production Production 100 0 E gt 8 2012 07 2409 55 23 422 USER 0002LIneA1 0x0000 ProductionFinished 9 n 9 2012 07 2410 15 00 549 SQL 0003SELECT 0x0000 MyDatabase2 4 TABLE_MPS ProductionSchedule 200 0 Precautions for Correct Use Do not delete the latest log file DB_ExecutionLog log and the log control file DB_ExecutionLog fjc from the SD Memory Card If they are deleted the log files are not saved correctly for example the Execution Log data are lost NJ series Database Connection CPU Units User s Manual W527 6 9 6 How to Use Operation Logs 6 3 Debug Log 6 3 1 This section describes the Debug Log used for debugging the DB Connection Service Overview You can check which SQL statement is executed parameters of each SQL statement and execution results with the Debug Log You can record this log by clicking the Start Button for Debug Log in the Online Settings Tab Page of Sysmac Studio You can also record a specified log as Debug Log by executing a DB_PutLog Record Operation Log instruction This log is saved as Debug Log files on the SD Memory Card mounted in the CPU Unit When no SD Memory Card is mounted in the CPU Unit you cannot record the Debug Log You can check the contents of this log in the Debug Log Tab Page of the Operation Log Window in Sysmac Studio EN Additional Information The Debug Log is used to check the parameters and execution results of the SQL state
56. This instruction cannot be executed because one or more SQL statements are already stored in the Spool memory 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress 3016 hex DB in Process The instruction was executed before completion of the DB s processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_Update DB_Select or DB_Delete instruction NJ series Database Connection CPU Units User s Manual W527 A 35 iw Ww O O 5 5 oO QO O 5 D o c Q O 5 D j s ga p10094 gq 93491149H Appendix A Function This instruction is used to retrieve records from a table mapped by a DB_CreateMapping instruction into the DB Map Variable specified in the MapVar in out variable Define the DB Map Variable as an array when you want to retrieve more than one record The number of records retrieved to the DB Map Variable is output to the RecCnt output variable The number of records retrieved according to the retrieval conditions is output to the SelectedCnt output variable The relationship between the number of array elements in the DB Map Variable and the number of records in the RecCnt and SelectedCnt output variables is described below When the number of array elements of the DB Map Variable is equal to or smaller than lt the number of retrie
57. Unit Built in EtherNet IP Port User s Manual Cat No W506 for details on the settings NJ series Database Connection CPU Units User s Manual W527 2 9 2 DB Connection Settings Communications Test You can test the connection to the DB according to the settings made in the Connection Settings of Sysmac Studio This is not the DB Connection Settings that have been transferred to the Controller You can perform the communications test while Sysmac Studio is online with the Controller 1 Use the Synchronization function to transfer the DB Connection settings from the computer to the Controller 2 Click the Communications Test Button under DB Communications Test 3 The result of the communications test is displayed in the text box under the Communications Test Button When the connection to the server failed from any cause the SQL status error code and detailed error message will be displayed SQL status Error code defined in the SQL Standards ISO IEC 9075 Error code Error code specific to the vendor of DB to connect When a network failure has occurred 0 is displayed for error code in some cases When 0 is displayed check its SQL status Detailed error message Error message specific to the vendor of DB to connect f Spool Settings Make the settings related to Spool function in the Spool Settings Configurations and Setup Spooling Spooling Use Donotuse en Resend spool data Au
58. Updates the values of a record of a table with the values of a DB Map Variable DB_Select Retrieve DB Retrieves records from a table toa Record DB Map Variable DB_Delete Delete DB Record Deletes the records that match the conditions from a specified table DB_ControlService Control DB Connection Service Starts stops the DB Connection Service or starts finishes recording to the Debug Log DB_GetServiceStatus Get DB Connection Service Status Gets the current status of the DB Connection Service DB_GetConnectionStatus Get DB Connection Status Gets the status of a DB Connection DB_ControlSpool Resend Clear Spool Data Resends or clears the SQL statements spooled by DB_Insert Insert DB Record and DB_Update Update DB Record instructions DB_PutLog Record Operation Log Puts a user specified record into the Execution Log or Debug Log DB_Shutdown Shutdown DB Connection Service Shuts down the DB Connection Service Refer to Appendix DB Connection Instructions for details and sample programming of each instruction NJ series Database Connection CPU Units User s Manual W527 3 18 3 5 4 System defined Variables 3 Programming the DB Connection Function You can use the following system defined variable in the DB Connection Service Variable name Member name Data type Meaning Function Initial value _DBC_ Status _sDBC_STATUS
59. User s Manual W527 Appendix A DB_ Close Close DB Connection The DB_Close instruction closes the connection with the DB established by a DB_Connect Establish DB Connection instruction Instruction Name FB FUN Graphic expression ST expression DB_ Close Close DB FB y DB_Close_instance Execute Connection DB_Close_instance DBConnection Done Busy Error DB_Close ErrorlD Execute Done DBConnection Busy Error ErrorlD Note The DB_Close_instance is an instance of DB_Close instruction which is declared as a variable we Variables pe O j S Input Variables 2 a nn e gt Lan Ci Name Meaning Data type Valid range Unit Default Description o Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition 5 a DBConnection DB DWORD 16 00000000 to Specify the DB Connection established Connection 16 FFFFFFFF by a DB_Connect instruction 2i S 7 i Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or TRUE when the instruction is normally z FALSE completed lo Busy Executing BOOL TRUE or aa TRUE when the instruction is being executed F D FALSE O Error Error BOOL TRUE or TRUE when the instruction is terminated due to 9 FALSE an error D J ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs w 16 F FFF Q le 5 3 9 Related System defined
60. W527 7 Troubleshooting 7 2 2 Error Descriptions Controller Error Descriptions The items that are used to describe individual errors events are described in the following copy of an error table Event name Gives the name of the error Event code Gives the code of the error Meaning Gives a short description of the error Source Gives the source of the error Source details Gives details on Detection Tells when the timing the source of the error is error detected Error attributes Level Tells the level of Recovery Gives the Log category Tells which log influence on recovery the error is control method saved in Effects User program Tells what will Operation Provides special information on the operation that happen to results from the error execution of me N user program N System defined Variable Data type Name a variables Lists the variable names data types and meanings for system defined variables that provide direct error notification that are directly affected by the error or that contain settings that cause the error z Cause and Assumed cause Correction Prevention 2 correction Lists the possible causes corrections and preventive measures for the error 8 Attached This is the attached information that is displayed by Sysmac Studio or an NS series PT 2 information Precautions Provides precautions restrictions and supplemental information If
61. a category Log Code Displays a log code Log Name Displays a log name Result Displays results Connection Name Displays a DB Connection name Serial ID Displays a serial ID 6 24 NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs Detailed information The Details parameter of the log is displayed Buttons Upload Button The log files are uploaded from the Controller A list of log files is displayed in the following Operation Log Dialog Box Name Size Updated DB_ExecutionLog log 503 KB 1 30 2013 5 46 26 PM DB_ExecutionLog_20130128095821 log 778 KB 1 28 2013 9 58 20 AM Select a log file to display and click the OK Button The log file is uploaded Execution Log Tab Page Execution Log is uploaded from the Controller Debug Log Tab Page Debug Log is uploaded from the Controller e SQL Execution Failure Log Tab Page SQL Execution Failure Log is uploaded from the Controller s6o7 uoneiado y Buyoya 9 9 Note 1 If the same name log file exists in the computer the following message is displayed The same name log file already exists in the computer DB_ExecutionLog_20130128095821 log Do you want to upload the file again Yes No Cancel Click a button Yes The specified file is uploaded from the Controller and displayed No The specified file is not uploaded from the Controller and the contents of the file that already exists in the compute
62. a suffix to the catalog number on the front and back covers of the manual Cat No W527 E1 02 f Revision code Revision code Date Revised content 01 April 2013 Original production 02 August 2013 Added description of the time specified for timeout of DB Connection Instructions P5 10 A 16 A 21 A 37 and A 41 e Corrected mistakes 30 NJ series Database Connection CPU Units User s Manual W527 Introduction to the DB Connection Service This section provides an introduction to the DB Connection Service 1 1 1 2 1 3 NJ series Database Connection CPU Units User s Manual W527 Overview and Features 1 1 1 OVEIVICW A fit tii chan ee te thee tt Ae OR eto 1 1 2 Features iccnct nied aii lel atid aaa DB Connection Service Specifications and System 1 2 1 DB Connection Service Specifications 0 ccceeceeeeeeeeeeteeeeeeeeees 1 2 2 DB Connection System Operation Flow of the DB Connection Service 1 1 1 Introduction to the DB Connection Service 1 1 1 1 1 1 1 2 Overview and Features This section describes the overview and features of the DB Connection Service Overview The DB Connection Service is a function to insert update retrieve and delete records to from a relational database hereinafter called DB on a server connected to the built in EtherNet IP port of an NJ series CPU Unit by executing special instructions called DB Connection Instruct
63. an an eee wy Lot No t DDM XXXX J Lot number and serial number MAC address The following information is provided on the ID information label Item Description Unit model Gives the model of the Unit Unit version Gives the unit version of the Unit DB Connection Gives the name and version of the DB Connection Service implemented in the Unit Service name and version Lot number and Gives the lot number and serial number of the Unit serial number DDMYY Lot number L For use by OMRON xxxx Serial number M gives the month 1 to 9 January to September X October Y November Z December MAC address Gives the MAC address of the built in port on the Unit i Confirming Unit Versions with Sysmac Studio You can use the Unit Production Information on Sysmac Studio to check the unit version of the CPU Unit CJ series Special I O Units and CJ series CPU Bus Units The unit versions of CJ series Basic I O Units cannot be checked from Sysmac Studio 26 NJ series Database Connection CPU Units User s Manual W527 e CPU Unit and CJ series Units Unit Versions 1 Double click CPU Expansion Racks under Configurations and Setup in the Multiview Explorer Or right click CPU Expansion Racks under Configurations and Setup and select Edit from the menu The Unit Editor is displayed in the Configurations and Setup layer of the Edit Pane 2 Right click any open space in the Un
64. ana ae T A NNE 5 2 5 1 2 Spooling System sia wee eee aiina aatia adaa naidi aerian 5 2 5 1 3 Applicable Instructions and Spooling Execution Conditions 5 2 5 1 4 Memory Area Used by the Spool Function 0 cccceeceeeeeeteeeeees 5 4 5 1 5 Spool Function Settings cccccceeeceeeceeeeeeeeeeeeeeeseeeeeeseaeeseneeseeeees 5 5 5 1 6 How to Resend the SQL Statements Stored in the Spool Memory 5 6 5 1 7 Clearing the SQL Statements from the Spool Memory 08 5 7 5 1 8 Relationship with the DB Connection InstructionS c cee 5 9 5 1 9 How to Estimate the Number of SQL Statements that Can be Spooled cccccccceeeeeeeceeeeeseceeeeeaaeseeeeeseeeesnaeeseeeeeaes 5 11 5 2 DB Connection Service Shutdown FUNCTION cceeeeeeeeeeeeeeeeseeeeeeeeeneees 5 12 5 2 1 COVEIVICW rarae treaties a a ed rab i esha E 5 12 5 2 2 Shutdown SyStOM 0 ccecceeeeeceeeeeeceeeeeeeceeeeesaeeeseseeseeeeseaeessaeeeenees 5 13 5 2 3 How to Execute the Shutdown Fun ction c cccscceeeseeeseeeeeeneeees 5 13 5 2 4 How to Check the Shutdown of the DB Connection Service 5 14 5 3 How to Prevent Losing SQL Statements at Power Interruption 5 15 5 3 1 OVEIVICW evicted delet Shasta EA eb ee E ede ence bes ean 5 15 5 3 2 Procedur S err fh tae yateecetacs tha sath a a a ea 5 15 5 4 Timeout Monitoring FUNCTIONS 00 0 0 eee eeeeeeeeeeeeeeeeeeeeaeeeeeeeeeeeeeteaeeeeeeeaeaes 5 19 5 4 1 Timeout Monitoring Fu
65. be installed within a control panel e You must use reinforced insulation or double insulation for the DC power supplies connected to DC Power Supply Units and I O Units e NJ series Controllers that comply with EC Directives also conform to the Common Emission Standard EN 61000 6 4 Radiated emission characteristics 10 m regulations may vary depending on the configuration of the control panel used other devices connected to the control panel wiring and other conditions You must therefore confirm that the overall machine or equipment complies with EC Directives NJ series Database Connection CPU Units User s Manual W527 17 Regulations and Standards Conformance to Shipbuilding Standards The NJ series Controllers comply with the following shipbuilding standards Applicability to the shipbuilding standards is based on certain usage conditions It may not be possible to use the product in some locations Contact your OMRON representative before attempting to use a Controller on a ship f Usage Conditions for NK and LR Shipbuilding Standards e The NJ series Controller must be installed within a control panel e Gaps in the door to the control panel must be completely filled or covered with gaskets or other material e The following noise filter must be connected to the power supply line Noise Filter Manufacturer Model Cosel Co Ltd TAH 06 683 Software Licenses and Copyrights 18 This product incorporates certain thir
66. changes to FALSE Ladder Diagram Main Variables Name Data type Initial value Comment DB_ControlService_instance DB_ControlService Instance of DB_ControlService instruction z LogOn BOOL FALSE Variable used as a trigger for controlling the Debug Log Q Operating BOOL FALSE The DB_ControlService instruction is executed when this j variable is TRUE Q OperatingEnd BOOL FALSE This variable changes to TRUE when the 5 DB_ControlService instruction is completed gt RS_instance RS Instance of RS instruction g MyCmd _eDBC_CMD This variable is assigned to the Cmd input variable to 5 5 n DB_ControlService_instance ControlService_OK BOOL FALSE This variable changes to TRUE when the DB_ControlService instruction is completed normally Sample Programming Start recording to the Debug Log when the variable LogOn changes to TRUE and finish the recording when the variable LogOn changes to FALSE Check the completion of DB_ControlService instruction DB_ControlService_instance Done OperatingEnd DB_ControlService_instance Error Accept the trigger for controlling the Debug Log 1s Ww Q S n lt re 0 RS_instance Operating RS Set Q1 OperatingEnd Reset1 2 m S uo2 uuo gq 1014409 NJ series Database Connection CPU Units User s Manual W527 A 57 Appendix A Start recording to the Debug Log eDBC_CMD _DBC_C
67. correct because the power supply to the Controller was interrupted during a Restore operation Non volatile memory failed 85100000 hex DB Connection Disconnected Error The DB Connection was disconnected due to an error The power supply to the server is OFF The DB is stopped in the server The Ethernet cable connector is disconnected The Ethernet cable is broken Noise 7 8 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event code Event name Meaning Assumed cause Level Reference Maj Prt Min Obs Info 95300000hex DB The DB The DB Connection Service Connection Connection was successfully started s Service Service was Started started 9531 0000hex DB The DB The DB Connection Service Connection Connection was stopped s Service Service was Stopped stopped 95320000hex DB The DB The DB Connection Service Connection Connection was shut down s Service Service was shut Shutdown down Buljooysejqnol Z Z aN JqE L 1011F Z Z NJ series Database Connection CPU Units User s Manual W527 7 9 7 Troubleshooting Errors Related to DB Connection Instructions Errors are given as event codes that use the error code as the lower four digits For descriptions of an error code refer to the description of the corresponding event code For example if
68. failure occurred in information exchange between DB Connection Service and DB When an SQL statement cannot be executed because one or more SQL statements are stored in the Spool memory 607 aunjre4 uoNnndexy TOS v 9 4 Log Name Category Operation Log name SQL Execution Failed INSERT INSERT UPDATE UPDATE SELECT SELECT DELETE DELETE Spooled INSERT INSERT UPDATE UPDATE Status Error INSERT INSERT UPDATE UPDATE SELECT SELECT DELETE DELETE Log file example 1 2012 07 24 09 00 00 200 SQL_FAIL 0001 INSERT 0x300B MyDatabase1 0 17072 ORA 17072 Inserted value too large for column INSERT INTO TABLE_Production Column1 VALUES 1000 2 2012 07 24 09 01 13 550 SPOOL 0001 INSERT 0x3012 MyDatabase1 15 INSERT INTO TABLE_Production Column2 VALUES 200 3 2012 07 24 09 01 14 050 SPOOL 0001 INSERT 0x3014 MyDatabasel 18 INSERT INTO TABLE_Production Column2 VALUES 300 4 2012 07 24 09 01 14 550 STATUS_ERROR0001 INSERT 0x300C MyDatabase1 19 INSERT INTO TABLE_Production Column2 VALUES 400 Precautions for Correct Use Do not delete the latest log file DB_SQLFailedLog log and the log control file DB_SQLFailedLog fjc from the SD Memory Card If they are deleted the log files are not saved correctly for example the SQL Execution Failure Log data are lost sis T a ep O F m x fo O Sri 2 a ro fo a 7 ep O D Q re
69. given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks 7 34 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name DB Connection Instruction Execution Timeout Event code 54013012 hex Meaning The instruction was not completed within the time specified for timeout Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction The power supply to the serveris Check the server status and start it Check the server status and start it OFF properly properly The Ethernet cable connector is Reconnect the connector and Connect the connector securely disconnected make sure it is mated correctly The Ethernet cable is broken Replace the Ethernet cable None The server s processing time is Check the server s response time Check the server s respons
70. i e when the Error output variable changes from FALSE to TRUE The response time is stored when a normal response is returned from the DB after the DB Connection Instruction Execution Timeout occurred This value is cleared when the DB Connection Service is started Duration Unit d h m s ms Spooling Number of spool data Number of SQL statements stored in the Spool memory Number of spool data Spool usage Use rate of the Spool memory for each DB Connection Spool usage in percentage Connection SQL status Error Error code defined in SQL Standards ISO IEC 9075 to be shown when a network failure or an SQL Execution Error occurred The value of the latest error in the connection is stored This value is cleared when the DB Connection Service is started Error code Error code that is specific to DB vendor to be shown when a network failure or an SQL Execution Error occurred When a network error has occurred 0 is displayed for error code in some cases When 0 is displayed check its SQL status The code of the latest error in the connection is stored This value is cleared when the DB Connection Service is started Error message Error message that is specific to DB vendor to be shown when a network failure or an SQL Execution Error occurred The message of the latest error in the connection is stored This value is cleared when the DB Connection Service is started
71. in DB_CreateMapping 16 FFFFFFFF DB_Insert DB_Update DB_Select DB_Delete and DB_Close instructions Related System defined Variables Online Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used _EIP_EtnOnlineSta A 6 NJ series Database Connection CPU Units User s Manual W527 Related Error Codes Appendix A Error code Meaning Description 0406 hex Illegal Data Position Specified The DBConnectionName input variable is a text string consisting of NULL characters 16 00 only 0410 hex Text String Format Error A space character is included in the text string specified for the DBConnectionName input variable The DBConnectionName input variable does not end in NULL 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same Same Time time 3000 hex DB Connection Service not Started The instruction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was shut Shutting Down down or while the DB Connection Service was being shut down 3003 hex Invalid DB Connection Name The DB Connection name specified in the DBConnectionName input variable is not set in any DB Connection Settings 3004 hex DB Connection Rejected The
72. information of the SQL statement DB Select instruction being sent at power interruption as retrieval condition y Already reflected into the DB Records retrieved NO oo yV Create a DB Map Variable DB_CreateMapping for resend instruction Re execute the DB_Insert instruction DB_Insert instruction Close the DB Connection DB_Close instruction END NJ series Database Connection CPU Units User s Manual W527 5 17 5 Other Functions When a DB_Update instruction is being executed START YES y Read output parameters of Busy and SendStatus output variables 1st cycle of the operation Values of output parameters of Busy and SendStatus output variables Busy TRUE and SendStatus _DBC_SEND_SENDING Resend processing required Others Resend processing not required Change the output parameters of Busy and SendStatus output variables to initial values Resend processing required Vv Create a DB Map Variable eats for resend DB_CreateMapping ins Re execute the DB_Update instruction DB_Update instruction Close the DB Connection DB_Close instruction END l Precautions for Correct Use The value of the SendStatus output variable is overwritten Establish a DB Connection DB_Connect i
73. of a NULL 16 00 character only was specified in the Where input variable 7 12 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event code Event name Meaning Assumed cause peu Reference Maj Prt Min Obs Info 54013010hex Log Code Out The value of the A value outside the valid of Range entered log code range from 0 to 9999 was s is outside the specified valid range 54013011hex DB The instruction The power supply to the Connection could not be server is OFF Disconnected executed The DB is stopped in the Error Status because the DB server Connection had The Ethernet cable S been connector is disconnected disconnected The Ethernet cable is due to an error broken Noise 54013012hex DB The instruction The power supply to the Connection was not server is OFF Instruction completed within The Ethernet cable Execution the time connector is disconnected s Timeout specified for The Ethernet cable is timeout broken The server s processing time is long 54013013hex DB The instruction The DB Connection settings Connection could not be are corrupted Service Error executed Stop because the DB s Connection Service was stopped due to an error 54013014hex Data Already One or more A DB_Insert or DB_Update Spooled SQL statements instruction was executed are already when one o
74. processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur This instruction cannot be executed without specifying the retrieval conditions Ifthe values cannot be registered to the DB for example because the SQL statement is invalid this instruction is terminated due to an error without storing the SQL statement into the Spool memory When the DB Connection Service was started in Test Mode this instruction is completed normally without executing the UPDATE operation for the DB actually When the error code is 300B hex SQL Execution Error you can get the detailed information of the SQL Execution Error by executing a DB_GetConnectionStatus instruction The measurement error of timeout is 10 ms as a guide However the measurement error may vary if enough execution time cannot be secured for the system service When two or more DB Connection Instructions are executed for a DB Connection at the same time the DB Connection Service executes the instructions one by one The measurement of timeout for the second and later instructions is started when the instruction is executed by the DB Connection Service not when the Execute input variable is changed to TRUE Therefore the time from when the Execute input variable is changed to TRUE to when the timeout occ
75. processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_Update DB_ Select or DB_Delete instruction When 32 or more DB Connection Instructions were executed at the same time w W O O 5 5 oO QO O 5 D o c QO O 5 D puod9ey ga aw pdn eyepdn ga NJ series Database Connection CPU Units User s Manual W527 A 21 Appendix A Sample Programming This section gives sample programming for the following operations Insert production data into a specified DB when the trigger variable changes to TRUE Update production data in a specified DB when the trigger variable changes to TRUE fl DB Connection Settings and Data Type Definition The minimum settings necessary for the sample programming are shown below DB Connection Settings DB Connection name MyDatabase1 Structure Data Type Definition Name Data type PRODUCTION_INSERT STRUCT Name STRING 256 LotNo STRING 32 Status STRING 8 ProductionDate DATE Name Data type PRODUCTION_UPDATE STRUCT Status STRING 8 FinishTime DATE_AND_TIME Ladder Diagram Main Variables Name Data type Initial value Comment _DBC_Status _sDBC_STATUS System defined variable that shows the status of the DB Connection Service DB_Connect_instance DB_Connect Instance of DB_Connect instruction MyDB1 DWORD This variable is assig
76. que la limitation ou l exclusion ci dessus ne s appliquera pas votre gard EFFET JURIDIQUE Le pr sent contrat d crit certains droits juridiques Vous pourriez avoir d autres droits pr vus par les lois de votre pays Le pr sent contrat ne modifie pas les droits que vous conf rent les lois de votre pays si celles ci ne le permettent pas Oracle Technology Network Development and Distribution License Terms Export Controls on the Programs Selecting the Accept License Agreement button is a confirmation of your agreement that you comply now and during the trial term with each of the following statements You are not a citizen national or resident of and are not under control of the government of Cuba Iran Sudan Libya North Korea Syria nor any country to which the United States has prohibited export You will not download or otherwise export or re export the Programs directly or indirectly to the above mentioned countries nor to citizens nationals or residents of those countries You are not listed on the United States Department of Treasury lists of Specially Designated Nationals Specially Designated Terrorists and Specially Designated Narcotic Traffickers nor are you listed on the United States Department of Commerce Table of Denial Orders You will not download or otherwise export or re export the Programs directly or indirectly to persons NJ series Database Connection CPU Units User s Manual W527 21
77. record processing instructions such as DB_Insert DB_Update and DB_ Select instructions DB mapping Create a structure data type for DB access Refer to 3 2 Creating a Structure Data Type Create a variable called DB Map Variable using the above structure Refer to 3 3 Creating a DB Map Variable Establish a DB Connection by executing a DB_Connect Establish DB Connection instruction Refer to 4 2 Establishing Closing a DB Connection Create a mapping from the DB Map Variable to a specified table by executing a DB_CreateMapping Create DB Map instruction for each SQL type i e INSERT UPDATE and SELECT Refer to 3 4 Specifying the Table and Applying the Mapping DB read write Execute the DB_Insert Insert DB Record DB_Update Update DB Record and DB_ Select Retrieve DB Record instructions Refer to 3 5 Programming Using the DB Connection Instructions The DB mapping means to assign each member of a structure for DB access to each column of a table You need to execute the DB mapping for each SQL type i e INSERT UPDATE and SELECT NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function 3 2 Creating a Structure Data Type To access a DB you need to create a user defined structure data type according to the table definition of the DB This section describes the specificati
78. s ms This value is cleared when Connection changes from Closed to Connected Disconnection date time Date and time when the DB is disconnected due to a Date and time network failure server s problem or other causes This value is cleared when the DB Connection Service is started Query Number of normal Number of times when an SQL statement is normally Number of normal Execution executions executed executions Including the number of times when a spooled SQL statement is resent This value is cleared when the DB Connection Service is started 4 12 NJ series Database Connection CPU Units User s Manual W527 Category Item 4 Basic Operations and Status Check Description Values Number of error executions Number of times when an SQL statement execution failed This is the number of times when an SQL statement is not spooled but discarded The number of times when a statement is spooled is not included This value is cleared when the DB Connection Service is started Number of error executions Response time Time elapsed since the CPU Unit sent the SQL statement until the CPU Unit received its SQL execution result in the latest execution of SQL statement The response time is stored only when normal response is returned from the DB If a DB Connection Instruction Execution Timeout has occurred the response time is not stored when the execution of the instruction is completed
79. status of D the DB Connection Service DB_Connect_instance DB_Connect Instance of DB_Connect instruction I MyDB1 DWORD _ Variable that is assigned to the DBConnection 2 output variable from DB_Connect_instance 3 LotNo UINT 1234 Variable to specify the lot number for retrieving deleting DB records Trigger_Connect BOOL FALSE Variable used as a trigger for establishing a DB Connection LastTrigger_Connect BOOL FALSE Variable to retain the trigger status of the previous execution Operating_Connect BOOL FALSE The DB_Connect instruction is executed when this variable is TRUE OperatingStart_Connect BOOL FALSE The start processing for establishing the DB Connection is executed when this variable is NJ series Database Connection CPU Units User s Manual W527 A 47 Appendix A Name Data type Initial value Comment TRUE DB_CreateMapping_Select_instance DB_CreateMapping Instance of DB_CreateMapping instruction MapVar_Select ARRAY 0 99 OF This variable is assigned to the MapVar input PRODUCTION_SEL variable to DB_CreateMapping_Select_instance ECT DB_Select_instance DB_Select Instance of DB_Select instruction Trigger_Select BOOL FALSE Variable used as a trigger for retrieving DB records LastTrigger_Select BOOL FALSE Variable to retain the trigger status of the previous execution Operating_Select BOOL FALSE The DB_Select instruction is execut
80. table lists the phenomena that we confirmed under our measurement environment and their countermeasures No Phenomena 1 After the power supply to the CPU Unit was turned ON execution time of the first DB Connection Instruction i e DB _Insert DB Update DB_ Select or DB_Delete instruction got longer 2 After execution of a DB_CreateMapping instruction execution time of the first DB_Insert instruction got longer 3 When communications or SD Memory Card processing was executed in the CPU Unit execution time of a DB Connection Instruction got longer 4 Execution time of DB Connection Instructions is steadily long 5 Depending on the DB s status execution time of a DB Connection Instruction i e DB_Insert DB_Update DB Select or DB_Delete instruction got longer Phenomenon 1 After the Power Supply to the CPU Unit was Turned ON Execution Time of the First DB Connection Instruction i e DB_Insert DB_Update DB Select or DB_Delete instruction Got Longer e Possible causes The following can be the causes 7 For the first DB Connection Instruction i e DB_Insert DB_Update DB_Select or DB_Delete instruction that is executed after the power supply to the CPU Unit is turned ON the CPU Unit may require longer processing time than usual 2 For the first DB_Insert instruction that is executed after execution of a DB_CreateMapping instruction the DB may require longer processing time than usual The f
81. the TableName input variable 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same Same Time time 3000 hex DB Connection Service not Started The instruction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was shut Shutting Down down or while the DB Connection Service was being shut down 3008 hex Invalid DB Connection The value of the DBConnection input variable is invalid or the specified DB Connection is already closed 300B hex SQL Execution Error The executed SQL statement resulted in an error in the DB 300E hex Invalid Retrieval Conditions The Where input variable is a text string consisting of NULL characters 16 00 only 3011 hex DB Connection Disconnected Error Status The DB Connection Service cannot communicate with the DB due to a network failure or other causes 3012 hex DB Connection Instruction Execution The instruction was not completed within the time specified in the Timeout TimeOut input variable 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3014 hex Data Already Spooled This instruction cannot be executed because one or more SQL statements are already stored in the Spool memory 3015 hex DB Connection Service Initializing The instruction was executed while the in
82. the error code for the instruction is 16 3000 refer to the description for event code 5401 3000 hex Event code Event name Meaning Assumed cause bevel Reference Maj Prt Min Obs Info 54013000hex DB The DB A command to start the DB Connection Connection Connection Service was not Service Not Service has not given before the execution of Started been started relevant instruction s A command to stop the DB Connection Service was given before the execution of relevant instruction 54013001 hex DB Failed to change Run mode change to Test Connection the Run mode of Mode was executed by the Service Run the DB relevant instruction while Mode Change Connection running in Operation Mode Failed Service Run mode change to Operation Mode was executed by the relevant instruction while running in Test Mode 6 Start of the DB Connection Service was commanded while the DB Connection Service was being stopped Shutdown of the DB Connection Service was commanded while the DB Connection Service was being stopped 5401 3002hex DB The DB The relevant instruction was Connection Connection executed after the DB Service Service is Connection Service was shut Shutdown or already shut down Shutting Down down or being The relevant instruction was S shut down executed while the shutdown processing of the DB Connection Service was in progress 54013003hex Invalid DB The s
83. the Default 30 seconds above figure Time until the DB Connection Service detects an error when the DB takes time for query execution You can cancel the SQL operation when the DB takes longer than expected for query execution Refer to 2 2 2 DB Connection Settings Communications Time specified for Query Time until the DB Connection Service timeout b in the execution timeout plus detects an error due to a above figure 10 seconds communications failure between DB Connection Service and DB Instruction execution Not monitored or Time until the DB Connection Service Refer to Appendix timeout c in the 0 05 to180 seconds detects an error when a DB_Insert DB Connection above figure Default Not monitored DB_Update DB_Select or DB_Delete Instructions instruction takes time due to a communications failure between DB Connection Service and DB or server s problem or heavy load You can use this when you do not want to extend the takt time i e lower the equipment performance Keep Alive monitoring 1 to 65535 seconds This function is used to check whether Refer to the time Default 300 seconds the server is normally connected When you set this Keep Alive monitoring time a communications failure can be detected even while the DB Connection Service is waiting for a response from the server because the DB is executing a query NJ series CPU Unit Built in EtherNet IP Port User s Manual Cat No
84. the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur If you execute this instruction before completion of a DB_Connect instruction and confirm that the connection status of the DB Connection is Connected an instruction error Invalid DB Connection may occur when you execute the next DB Connection Instruction When you use the DBConnection output variable from the DB_Connect instruction confirm that the Done output variable of the DB_Connect instruction is TRUE or the value of the DBConnection output variable is not 16400000000 before executing the DB Connection Instruction An error occurs for this instruction in the following cases Error will be TRUE When the instruction was executed when the DB Connection Service was not running When the instruction was executed while the initialization processing of the DB Connection Service was in progress A 66 NJ series Database Connection CPU Units User s Manual W527 Appendix A When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or wh
85. the instruction instance DB_GetConnectionStatus_instance Execute FALSE DB_ControlSpool_instance Execute FALSE OperatingStart FALSE END_IF IF Operating TRUE THEN A 76 NJ series Database Connection CPU Units User s Manual W527 Get the status of the DB Connection DB_GetConnectionStatus_instance Execute TRUE DBConnectionName _ MyDatabase1 ConnectionStatus gt MyStatus IF DB_GetConnectionStatus_instance Done TRUE THEN Normal end processing Change the variable Resend to TRUE when the status of the DB Connection is Connected IF MyStatus Status _DBC_CONNECTION_STATUS_CONNECTED THEN Resend TRUE ELSE Resend FALSE Operating FALSE END_IF END_IF IF DB_GetConnectionStatus_instance Error TRUE THEN Error handler Operating FALSE END_IF END_IF IF Operating TRUE AND Resend TRUE THEN Resend the Spool data DB_ControlSpool_instance Execute TRUE DBConnection MyDB1 Cmd DBC _SPOOL_RESEND IF DB_ControlSpool_instance Done TRUE THEN Normal end processing Resend FALSE Operating FALSE END_IF IF DB_ControlSpool_instance Error TRUE THEN Error handler Resend FALSE Operating FALSE END_IF END_IF NJ series Database Connection CPU Units User s Manual W527 Appendix A A 77 J uW QO O 3 5 oO QO O 5 gt A 2 c QO O 3 na eeq joods sea D puesey joodsjouu0D gq App
86. the menu The following Online Settings Tab Page is displayed A Configurations and Setup wY Service Start Stop Shutdown v Debug Log Start Stop You can start and stop recording to the Debug Log by clicking the following buttons Category Item Button Operation Debug Log Start Stop Start Recording to the Debug Log is started Stop Recording to the Debug Log is stopped 2 Click the Start Button A confirmation message is displayed Online Settings 4 a Are you sure to start recording the debug log Y N Yes No 3 Click the Yes Button Start by executing a DB_ControlService Instruction Specify Start recording to Debug Log in the Cmd input variable of the DB_ControlService Control DB Connection Service instruction and execute the instruction Refer to Appendix DB Connection Instructions for details of the instruction 6 12 NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 3 5 Stopping Recording to Debug Log You can stop recording to the Debug Log by the following methods e Online operation from Sysmac Studio Executing a DB_ControlService Control DB Connection Service instruction e Automatically stopped when a specified condition is met i Stop by Online Operation from Sysmac Studio 1 Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer
87. timeb tasisunneiina i a a 2 9 Login TIMEOUT 5 20 Manual Resend e ccccccccccccesesssseeceeeceesesseceeeceseessaneeeees 5 6 Number of error executions cc cccccsseccessseecessseesenees 4 13 Number of normal executions 0 ccccccscecsseceeseseeeeeee 4 12 Number of spool data cccccccccccsccsseceseceeeceesteesteeceseensees 4 13 Operating tim Giice 8 vescsesetierdacnsartbenteeesatieaes 4 9 Operation Authority Verification in the DB Connection SOLVICGE ces seiesineei es eae te eben ook eet aees oe 5 24 Operation LOg i cecceccessecsseessceeeseeceeceeeceseceeceneeeeeneess A 29 Operation Log Disabled ccceceeseseesteeeeenecereeneeeeees 7 37 Operation Log function ceeeecceseceseceesceesteesteeeeeeeeaes 1 5 Operation Mode e cecccesseesseesseecseecesecesecesseeseeeeenees 2 5 4 2 Operation Status cccccccscccscssceeeeeseecseecesecesseesteeeeeeeeaes 4 9 Oracle Database s etseh teheer cuticle derivate caves 1 2 1 4 P Programming the DB Connection Service 000 3 16 Q Query Execution ccececcccsesseeeseecseeceeeceseeeseeeeeeeeseeess 4 12 NJ series Database Connection CPU Units User s Manual W527 Query execution timeout cee ecceseceseceeeceeseesteeeteeeenees 2 9 Query Execution Timeout 0 cece eeeeseeseeseeeecesecneeeneeees 5 20 resend the SQL statements eccseeseeseeeeeteenseeeeeeeeees 5 6 Response time ceeccccessseceessceeceeceeseeeceeea
88. to 65535 When exceeding 65535 this value returns to 0 The serial number is given across multiple files Even if a new file is created the serial number is not reset to 0 Date 10 bytes Fixed Displays year month and date when the log was recorded YYYY MM DD Example 2012 07 23 Time 8 bytes Fixed Displays hours minutes and seconds when the log was recorded K hh mm ss Example 15 33 45 Millisecond 3 bytes Fixed Displays 3 digit decimal integer 000 to 999 that shows millisecond of the time when the log was recorded Example 10 ms 010 623 ms 623 Category 16 bytes max Displays the category Variable Log code 4 bytes Fixed Displays a 4 digit decimal code that is a unique identification code in the category Log name 32 bytes max Displays a name that shows the contents of the log Variable NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs Parameter Size Description Result 6 bytes Fixed Displays a 4 digit hexadecimal code that shows the execution result e g 0x1234 0x0000 Succeeded Other than 0x0000 Failed Same code as Error D of DB Connection Instruction DB Connection 16 bytes max Displays a DB Connection name single byte alphanumeric characters name Variable When the category is DB Connection Service or User specified Log nothing is displayed Serial ID 10 bytes max ID code given at each exe
89. value of the LogCode input variable is outside the valid range e When the LogName input variable exceeds 33 bytes including the final NULL character e When the LogMsg input variable exceeds 129 bytes including the final NULL character e When the SD Memory Card is not available or write protected e When the log cannot be recorded because the specified Operation Log is disabled e When 32 or more DB Connection Instructions were executed at the same time Sample Programming This section gives sample programming for putting the following log record into the Execution Log when the trigger variable changes to TRUE e Log code 100 Log name Production Order Log message Production Start RecipeCode 12345678 i Ladder Diagram Main Variables Name Data type Initial value Comment DB_PutLog_instance DB_PutLog Instance of DB_PutLog instruction Trigger BOOL FALSE Variable used as a trigger for recording the user specified log Operating BOOL FALSE When this variable is TRUE recording of the user specified log is executed OperatingEnd BOOL FALSE This variable changes to TRUE when recording of the user specified log is completed RS_instance RS Instance of RS instruction RecipeCode UDINT 1234678 Recipe code used in the log message Msg STRING 256 Log message to record PutLog_OK BOOL FALSE This variable changes to TRUE when the DB_PutLog instruction is completed normally A 80 NJ series
90. you can map the DB Map Variable to the DB for each SQL type i e INSERT UPDATE and SELECT Refer to the explanation for DB_CreateMapping Create DB Map instruction in Appendix Structure data type definition used by a DB Tablet sana 5 Name LotNo TotalCount PCode Name STRING 256 LotNo UINT TotalCount UINT Pcode UINT Clearing the Mapping of DB Map Variables Mapping of DB Map Variables is automatically cleared by the following operations When the DB Connection is closed When the DB Connection Service is stopped When the DB Connection Service is shut down When another mapping is applied to the DB Map Variable i e mapping to a different table or for a different SQL type Refer to 4 1 3 DB Connection Service is Stopped or Cannot be Started for details on the stop of the DB Connection Service La Precautions for Correct Use Mapping to the DB is automatically cleared when the DB Connection is closed Therefore write the user program so that a DB_Connect Establish DB Connection instruction is executed before a DB_CreateMapping Create DB Map instruction NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function 3 4 3 Restrictions on DB Mapping The DB mapping has the following restrictions re e Restrictions on Table s Column Names N When a character that cannot be specified for structure member names is use
91. 0 6 3 1 OVSENE caine E A Ausra dane 6 10 6 3 2 Application Procedura arere rkr eea nae e e ERKA EKE EARE 6 10 6 3 3 Setting the Debug LOG eecececceeeeeseceeeeeeeeeeeeaeeseeeeeseaeessaeeeenees 6 11 8 NJ series Database Connection CPU Units User s Manual W527 CONTENTS 6 3 4 Starting Recording to Debug LOQ ccceccesteeeeeeeteeeeeeteeeeeeeees 6 12 6 3 5 Stopping Recording to Debug Log ccccceeseeeeeeeeseeeeeeteeeeeneeees 6 13 6 3 6 Checking the Debug Log c ccceecceeeeeeeeeeeeeeeseeeeeseaeeeeaeeeeneeees 6 14 6 3 7 Debug Log File Specifications 0 cceccceceeeeeeeeeeeeeeeeseeeesneeeeeeees 6 14 6 4 SQL Execution Failure LOQ ceseeseceessseeceeeeeeeeeeeseaneeeeenneeeeseseaeeeeesaaaees 6 18 6 4 1 OVENVICW satis E EA E ETEA A ATL E ATE 6 18 6 4 2 Application Procedure assssessssesserresrnrrnesrrrnesrnnnenennnesrnnnennnnneennnnne 6 18 6 4 3 Setting the SQL Execution Failure Log ccecseeeeeeeeeeeeeeeseeeees 6 18 6 4 4 Checking the SQL Execution Failure Log cccceeceeseeeeereees 6 19 6 4 5 SQL Execution Failure Log File Specifications ceeeeeee 6 19 6 5 SD Memory Card Operations eeecceceeeeeeeeeeeeneeeeeeeneeeeeeeseeeeeeseeeeeeeeaeaes 6 22 6 5 1 Saving Operation Log Files on SD Memory Card ceeee 6 22 6 5 2 Directory Used for DB Connection Service ccccccccsseeeeenees 6 22 6 5 3 Operation Log Operations in Replac
92. 2 or more DB Connection Instructions were executed at the same time J W 02 gt Q O z 891IM8S uoosuuo Gq UMOpPINUS NJ series Database Connection CPU Units User s Manual W527 A 85 Appendix A Sample Programming This section gives sample programming for shutting down the DB Connection Service when the trigger variable changes to TRUE A Ladder Diagram Main Variables Name Data type Initial value Comment DB_Shutdown_instance DB_ Shutdown Instance of DB_ Shutdown instruction Trigger BOOL FALSE Variable used as a trigger for shutting down the DB Connection Service Shutdown_OK BOOL FALSE This variable changes to TRUE when the DB_ Shutdown instruction is completed normally Sample Programming Shut down the DB Connection Service Shut down the DB Connection Service Trigger DB_Shutdown_instance Done DB_Shutdown_instance DB_Shutdown Execute Done Busy Error ErrorlD Structured Text ST Main Variables When the instruction is normally completed change the variable Shutdown_OK to TRUE Shutdown_OK Name Data type Initial value Comment DB_Shutdown_instance DB Shutdown Instance of DB_ Shutdown instruction Trigger BOOL FALSE Variable used as a trigger for shutting down the DB Connection Service LastTrigger BOOL FALSE Variable to retain the trigger status of the previous execution Operating BOOL FALSE Shutting down the DB Conne
93. 8 character code 6 6 2 Checking the Log on the Operation Log Window in Sysmac Studio You can check the Operation Logs i e Execution Log Debug Log and SQL Execution Failure Log stored in the SD Memory Card on the Operation Log Window in Sysmac Studio while online with the CPU Unit 7 Right click DB Connection under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Show Operation Logs from the menu while online with the CPU Unit The Execution Log Debug Log and SQL Execution Failure Log are displayed in the different tab pages 2 Click the Execution Log Tab Debug Log Tab or SQL Execution Failure Log Tab B opein tog _ erer Frtrv Date Time Catennry Lan Cadel nn Name Reailt Cannectinn Name 00001 1 24 2013 19 44 20 850 DB_CONNECTION 0001 Connect 0x0000 DB_Connect_2 00002 1 24 2013 19 44 30 507 SQL INSERT 0x0000 DB_Connect_2 0000000000 00003 1 24 2013 19 44 31430 SQL INSERT 0x0000 DB_Connect_2 0000000001 00004 1 24 2013 19 44 32430 SQL INSERT 0x0000 DB_Connect_2 0000000002 00005 1 24 2013 19 44 33430 SQL INSERT 0x0000 DB_Connect_2 0000000003 00006 1 24 2013 19 44 34 430 SOL INSERT 0x0000 DB Connect 2 0000000004 Details 12514 List view Detailed information Buttons The following information is displayed e List view Item Description Entry Displays a serial number Date Time Displays a date and time Category Displays
94. Appendix A Retrieve records for the specified lot number from the DB Connection MyDB1 when the variable Trigger_Select changes to TRUE Check the completion of the DB_ Select instruction DB_Select_instance Done OperatingEnd_Select DB_Select_instance Error Accept the trigger for retrieving DB records RS_Select_instance Operating_Select Trigger_Select ht Create the conditions for the Where and Sort clauses OperatingEnd_Select Operating_Select Create the conditions for Where clause LotNo XXXX 1 WhereCond_Select CONCAT LotNo UINT_TO_STRING LotNo Create the conditions for Sort clause Sort the production completion time in descending order SortCond_ Select FinishTime DESC Retrieve the records from the DB Connection MyDB1 Timeout is not monitored for the instruction execution DB_Select_instance Operating_Select DB Select Execute Done MyDB1 DBConnection Busy J uW QO O 3 5 oO QO O 5 gt A 2 c QO O 3 na WhereCond_ Select Where Error SortCond_Select Sort ErrorlD J T 0ms TimeOut RecCnt W MapVar_Select MapVar SelectedCnt J Q a When the instruction is terminated due to an error execute the error handler for the device FaultHandler_Select G Program the FaultHandler_Select according to the device D Operating_Select DB_Select_instance Error FaultHandler_S
95. B 2000 SQL statement to create DELETE FROM TableProduct Where ColumnA 1000 OR ColumnB 2000 Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur This instruction cannot be executed without specifying the retrieval conditions When the DB Connection Service was started in Test Mode this instruction is normally ended without executing the DELETE operation for the DB actually When the error code is 300B hex SQL Execution Error you can get the detailed information of the SQL Execution Error by executing a DB_GetConnectionStatus instruction The measurement error of timeout is 10 ms as a guide However the measurement error may vary if enough execution time cannot be secured for the system service When two or more DB Connection Instructions are executed for a DB Connection at the same time the DB Connection Service executes the instructions one by one The measurement of timeout for the second and later instructions is starte
96. Check Error In that case the Spool data is cleared In the DB Connection settings the default setting of Spooling is Use If you do not use the Spool function be sure to set Spooling to Do not use in the Spool Settings of the DB Connection settings and then download the DB Connection settings when you add a DB Connection If you download the DB Connection settings while Spooling is set to Use the values stored in the EM Bank No 9 to 18 will be overwritten by the initialization processing of the Spool function NJ series Database Connection CPU Units User s Manual W527 5 1 5 Spool Function Settings Right click a DB Connection name under Configurations and Setup Host Connection Settings DB Connection DB Connection Settings in the Multiview Explorer and select Edit from the menu A Configurations and Setup Y Spooling Set the Spool function in the Spool Settings Spooling Use Donotuse Resend spool data Auto Manual Clear condition Do not clear X 5 Other Functions Reset all to default 5 BENEI 4 Set the following items for the Spool function Item Description Values Spooling Set whether to use the spool function Use Default Do not use Resend spool data Set this item when you select Use for Spooling Set whether to resend the SQL statements stored in the Spool memory automatically or Auto Default Manual manually Clear condition Se
97. DB Connection Service Status Shows the operation status of the DB Connection Service Refer to 4 3 1 Operation Status of the DB Connection Service for details on the operation status of the DB Connection Service Run BOOL Running flag TRUE when the DB Connection Service is running in Operation Mode or Test Mode FALSE Test BOOL Test Mode TRUE when the DB Connection Service is running in Test Mode FALSE Idle BOOL Idle TRUE when the operation status of the DB Connection Service is dle FALSE Error BOOL Error Stop Flag TRUE when the operation status of the DB Connection Service is Error FALSE Shutdown BOOL Shutdown TRUE when the operation status of the DB Connection Service is Shutdown FALSE 3 5 5 Simulation Debugging of DB Connection Instructions You can perform operation check of the user program using the Simulation function of Sysmac Studio The DB Connection Instructions perform the following operations during simulation e The DB_ Connect DB_Close DB_Insert and other instructions that do not retrieve data will end normally The DB_Select and other instructions that retrieve data will end normally as if there was no applicable data 3 5 6 Transferring the DB Connection Settings and User Program You transfer the DB Connection settings and user program to an NJ series CPU Unit using the Synchronization function of
98. DB Connection Service Instruction Name FB FUN Graphic expression ST expression DB_GetService Get DB FB DB_GetServiceStatus_instance Status Connection DB_GetServiceStatus_instance Execute Done Busy Error Service Status ErrorlD ServiceStatus DB_GetServiceStatus Execute Done Busy Error ErrorlD ServiceStatus Note The DB_GetServiceStatus_instance is an instance of DB_GetServiceStatus instruction which is declared as a variable Variables fl Input Variables Name Valid range Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition i Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or aa TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or TRUE when the instruction is being FALSE executed Error Error BOOL TRUE or TRUE when the instruction is terminated FALSE due to an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error 16 FFFF occurs ServiceStatus DB Connection sDBC_SERVICE_STATUS Depends on Shows the status of the DB Connection Service Status the data type Service A 60 NJ series Database Connection CPU Units User s Manual W527 Appendix A Related Error Codes Error code Meaning Description 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at th
99. DB set in the DB Connection Settings rejected the connection 3005 hex DB Connection Failed The DB Connection Service cannot communicate with the DB due to a network failure or other factors The address set in the DB Connection Settings is wrong 3006 hex DB Connection Already Established A same name DB Connection is already established 3007 hex Too Many DB Connections The number of DB Connections that can be established at the same time is exceeded 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress Function This instruction is used to connect to the DB specified in the DBConnectionName input variable The DB Connection name is set in the DB Connection Settings on Sysmac Studio When this instruction is normally completed i e when the Done output variable changes to TRUE a DB Connection is established and a value is output to the DBConnection output variable This value is used to specify a DB Connection in some instructions described below NJ series Database Connection CPU Units User s Manual W527 A 7 T J D O D gt D o fa gt n n Cc S r fa D gt n se a lt sed je oF D n yosuuoy gq uo o uuop gq ysiqes3 Appendix A
100. DB_Connect established by a DB_Connect instruction instruction Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks 7 28 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name Invalid DB Map Variable Event code 5401 3009 hex Meaning The specified DB Map Variable is not correct Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction A structure variable that Specify a basic data type for the Confirm the data type of the contains a derivative data type members of the structure data used variables to be specified as a DB of member was specified a
101. DB_CreateMapping Create DB Map instruction takes effect Example Create Trigger DB_CreateMapping Members of MapVar1 variable Execute Done are mapped with columns of Connection1 DBConnection Busy Table Tablet TableName Error MapVar1 MapVar ErrorlD _DB_SQLTYPE_INSERT SQLType NJ series Database Connection CPU Units User s Manual W527 3 13 3 Programming the DB Connection Function Create2 Trigger DB_CreateMapping Execute Done Mapping members of MapVar1 variable with columns of Table of Connection1 is cleared Members of MapVar1 variable are mapped with columns of Table2 of Connection2 Connection2 DBConnection Busy Table2 TableName Error MapVar1 MapVar ErrorID _DB_SQLTYPE_INSERT SQLType e Restrictions on Mapping to Multiple SQL Types You cannot map a DB Map Variable for two or more SQL types If you execute multiple DB_CreateMapping Create DB Map instructions so as to map a single DB Map Variable for two or more SQL types the mapping made by the last DB_CreateMapping Create DB Map instruction takes effect Example Create Trigger DB cieeiaviapeing Members of MapVar1 variable Execute Done are mapped with columns of Connection1 DBConnection Busy Table Tablet TableName Error MapVar1 MapVar ErrorlD _DB_SQLTYPE_INSERT SQLType Create2 Trigger DB_CreateMapping Execute Done Mapping members of MapVar1 variable with columns of Table for INSERT
102. Data on the Data Type Editor 1 Double click Data Types under Programming Data in the Multiview Explorer 2 Click the Structures Side Tab of the Data Type Editor 3 Enter a data type name on the Structure Data Type Editor 4 Right click the structure name and select Create New Member from the menu Then enter a name and data type for each member 3 6 NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function Pasting the Data from Microsoft Excel onto the Data Type Editor 1 Use two columns on Microsoft Excel to enter names and data types from the left 2 In the 1st column enter the data type name of the structure on the 1st line and each member name from the 2nd line In the 2nd column always enter STRUCT on the 1st line to create a structure Enter the corresponding data type to the column s data type Data type name of A the structure Data type name B STRUCT lt Always STRUCT cn N O x oO w op a Cc g Cc oO J D fed lt O oO Member names 2 MemberName1 Enter the same 3 MemberName2 names as the MemberName3 column names of the table 6 MemberNameN 3 Copy the data area in the Name and Data type columns on Microsoft Excel 4 Paste the data onto the Name and Base Type columns of the Structure Data Type Editor Example Table name Column name DB s table definition
103. Debug Log This log is used for tracing which SQL statements were executed and parameters and execution result of each SQL statement 7 Right click DB Connection under Configurations and Setup Host Connection Settings and select Show Operation Logs from the menu and click the Debug Log Tab e SQL Execution Failure Log This log is recorded when an SQL execution failed in the DB 7 Right click DB Connection under Configurations and Setup Host Connection Settings and select Show Operation Logs from the menu and click the SQL Execution Failure Log Tab STEP 13 Checking the Event Log EO Troubleshooting NJ series Database Connection CPU Units User s Manual W527 1 11 1 Introduction to the DB Connection Service NJ series Database Connection CPU Units User s Manual W527 DB Connection Settings a This section describes how to make the initial DB Connection settings for using the DB Connection Service 2 1 Starting Sysmac Studio and Creating a New Project 2 1 1 Starting Sysmac Studio 2 1 2 Creating a New Project 2 1 3 Setting the Built in EtherNet IP Port 2 2 DB Connection Settings 2 2 1 DB Connection Service Settings 2 2 2 DB Connection Settings NJ series Database Connection CPU Units User s Manual W527 2 DB Connection Settings 2 1 Starting Sysmac Studio and Creating a New Project This section describes how to start Sysmac Studio and create a new project when using the DB Connection fu
104. Debug Log when the variable LogOn changes to TRUE Finish the recording when the variable LogOn changes to FALSE Start the sequence when the variable LogOn changes to TRUE IF LogOn TRUE AND LastTrigger FALSE THEN OperatingStart TRUE Operating TRUE MyCmd __DBC_CMD_DEBUGLOG_ON Start recording to the Debug Log ELSIF LogOn FALSE AND LastTrigger TRUE THEN OperatingStart TRUE Operating TRUE MyCmd __DBC_CMD_DEBUGLOG_OFF Finish recording to the Debug Log END_IF LastTrigger LogOn Sequence start processing IF OperatingStart TRUE THEN Initialize the instruction instance DB_ControlService_instance Execute FALSE OperatingStart FALSE END_IF Command to start or finish recording to the Debug Log IF Operating TRUE THEN Start or finish recording to the Debug Log DB_ControlService_instance Execute TRUE Cmd MyCmd IF DB_ControlService_instance Done TRUE THEN Normal end processing Operating FALSE END_IF IF DB_ControlService_instance Error TRUE THEN Error handler Operating FALSE END_IF END_IF NJ series Database Connection CPU Units User s Manual W527 Appendix A A 59 suonon suj uonosuuon gq w W Q S 09 2 lt re o Q91IMAS uo2 uuo gq 1014409 Appendix A DB_GetServiceStatus Get DB Connection Service Staus The DB_GetServiceStatus instruction gets the current status of the
105. Execution Error may occur again when the SQL statement is resent When the Spool capacity for each DB Connection is exceeded by spooling the SQL statement this instruction is terminated due to an error Spool Capacity Exceeded Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur Ifthe values cannot be registered to the DB for example because the SQL statement is invalid this instruction is terminated due to an error without storing the SQL statement into the Spool memory When the DB Connection Service was started in Test Mode this instruction is completed normally without executing the INSERT operation for the DB actually When the error code is 300B hex SQL Execution Error you can get the detailed information of the SQL Execution Error by executing a DB_GetConnectionStatus instruction The measurement error of timeout is 10 ms as a guide However the measurement error may vary if enough execution time cannot be secured for the system service
106. Expansion Error Code ErrorIDEx Precautions None Remarks 7 30 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name SQL Execution Error Event code 5401 300B hex Meaning The executed SQL statement resulted in an error Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction There is no column with the Check whether the column names Confirm that the column names same name as a structure match the structure member match the structure member member of the DB Map Variable names of the DB Map Variable names of the DB Map Variable The table specified in the Check whether the table name Confirm that the table name DB_CreateMapping instruction specified in the specified in the DB_CreateMapping does not exist in the DB DB_CreateMapping instruction is instruction is correct correct One or more structure member Check whether the data types of Confirm that the data types of the values of the DB Map Variable the structure members of the DB structure members of the DB Map cannot be converted to the Map Variab
107. GE TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U S 5 00 YOU CANNOT RECOVER ANY OTHER DAMAGES INCLUDING CONSEQUENTIAL LOST PROFITS SPECIAL INDIRECT OR INCIDENTAL DAMAGES This limitation applies to anything related to the software services content including code on third party Internet sites or third party programs and claims for breach of contract breach of warranty guarantee or condition strict liability negligence or other tort to the extent permitted by applicable law It also applies even if Microsoft knew or should have known about the possibility of the damages The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental consequential or other damages Please note As this software is distributed in Quebec Canada some of the clauses in this agreement are provided below in French NJ series Database Connection CPU Units User s Manual W527 Regulations and Standards Remarque Ce logiciel tant distribu au Qu bec Canada certaines des clauses dans ce contrat sont fournies ci dessous en frangais EXONERATION DE GARANTIE Le logiciel vis par une licence est offert tel quel Toute u
108. HERE is not included m oO TimeOut Timeout TIME T 0s T 0s Specify the time to detect timeout When D T 0 05s to T 180s T 0s is specified timeout is not D monitored D D D oO j Output Variables z a 3 ie JD Name Meaning Data type Valid range Unit Description Q Done Done BOOL TRUE or FALSE TRUE when the instruction is normally S completed Busy Executing BOOL TRUE or FALSE TRUE when the instruction is being executed Error Error BOOL TRUE or FALSE TRUE when the instruction is terminated due to an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF RecCnt Number of DINT 0 to 2147483647 Contains the number of records that were Records deleted NJ series Database Connection CPU Units User s Manual W527 A 39 Appendix A Related System defined Variables _EIP_EtnOnlineSta Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used Related Error Codes Error code Meaning Description 0400 hex Input Value Out of Range The value of the TimeOut input variable is outside the valid range 0406 hex Illegal Data Position Specified The TableName input variable is a text string consisting of NULL characters 16 00 only 0410 hex Text String Format Error A space character is included in the text string specified for
109. J501 1320 2 When two or more DB Connections are established the operation cannot be guaranteed if you set different database types for the connections 3 Refer to 5 1 9 How to Calculate the Number of SQL Statements that Can be Spooled for the information oT oO N 2 o 20 oO a oS 720 v e 50 as nw lt o 2 z 25 30 SUOITEDIIO9dS 249S UOIO UUOD gd L Z L NJ series Database Connection CPU Units User s Manual W527 1 5 1 Introduction to the DB Connection Service 1 2 2 DB Connection System This section describes the basic and other systems of the DB Connection function Refer to 1 3 Operation Flow of the DB Connection Service for the operation flow Basic System The following figure shows the basic system of the DB Connection function Sysmac Studio CPU Unit Server User Program A A c DB Connection Service DB Connection Instruction e Relational EtherNet IP port DB_Insert Database SQL statement DB Mapping d sent f INSERT DB access in Operation Mode DB table DB Map Variable b eoi Fas Fae FER DB Mapping d Structure data type Used as a data type for DB access a Mapping Basic System The numbers show the processing order Reference 1 Create a structure for NJ serie
110. MD_DEBUGLOG_ON Finish recording to the Debug Log LogOn eDBC_CMD _DBC_CMD_DEBUGLOG_OFF Command to start finish recording to the Debug Log DB_ControlService_instance Operating DB_ControlService Execute Done Cmd Busy Error ErrorlD When the instruction is normally completed change the variable Contro Service_OK to TRUE Operating DB_ControlService_instance Done Normal end processing ControlService_OK TRUE When the instruction is terminated due to an error change the variable Contro Service_OK to FALSE Operating DB_ControlService_instance Error J Error handler ControlService_OK FALSE Structured Text ST Main Variables Name Data type Initial value Comment DB_ControlService_instance DB_ControlService Instance of DB_ControlService instruction LogOn BOOL FALSE Variable used as a trigger for controlling the Debug Log LastTrigger BOOL FALSE Variable to retain the trigger status of the previous execution Operating BOOL FALSE The DB_ControlService instruction is executed when this variable is TRUE OperatingStart BOOL FALSE The initialization processing is executed when this variable is TRUE MyCmd _eDBC_CMD This variable is assigned to the Cmd input variable to DB_ControlService_instance A 58 NJ series Database Connection CPU Units User s Manual W527 Sample Programming Start recording to the
111. Memory Card power supply switch and insert a new SD Memory Card within five minutes after the SD PWR indicator is turned OFF If it takes more than five minutes Execution Log recorded in the internal buffer may be lost If the internal buffer space becomes full before inserting the SD Memory Card an Execution Log Save Failed Error is registered into the event log 6 5 4 Replacement Timing of SD Memory Card How to Know the Replacement Timing of the SD Memory Card You can know the replacement timing of the SD Memory Card by the SD Memory Card Life Exceeded Event or the SD Memory Card Life Warning Flag _Card1Deteriorated system defined variable NJ series Database Connection CPU Units User s Manual W527 6 23 P a op iw 3 fe lt O a O ke g wn G 9 pen owanw as y Buloej day ul suoeiado 607 uoeido g 6 How to Use Operation Logs 6 6 Checking the Operation Logs This section describes how to check the Operation Logs stored on the SD Memory Card mounted in the CPU Unit 6 6 1 How to Check the Operation Logs You can use the following methods to check the Operation Logs i e Execution Log Debug Log and SQL Execution Failure Log e Checking the log on the Operation Log Window in Sysmac Studio e Checking the log with the SD Memory Card e Checking the log by transferring data using FTP client software i Precautions for Correct Use Each Operation Log file is encoded by the UTF
112. NJ series Database Connection CPU Units User s Manual W527 1 Introduction to the DB Connection Service Other Systems The following figure shows the other systems of the DB Connection function Sysmac Studio walsks pue suoleoyioeds BdIM8S UONOBUUOD gad Z 4L User Program CPU Unit s erver DB Connection Service a N Relational DB Connection Instruction EtherNet IP database a DB_Insert DB access SQL statement DBConnection DB Mapping sent iea INSERT in Operation Mode When recovered n DB table N N J Ww Q 5 5 D o fe 3 io lt wo n D 3 DB Map Variable Status of the DB When transmission failed m abe Connection Service h Told Tel Data T EM Area non volatile memory ata ata Daat Errors and status of the DB Connection Service Spool memory System defined variable i INSERT Operation Logs k INSERT INSERT Event log j C Automatic saving p SD Memory Card 4 Log files 1 Other Systems Reference You can check the status of the DB Connection Service and each DB Refer to 4 Basic Operations Connection h in the above figure with the DB_GetServiceStatus Get DB and Status Check Con
113. OMRON Machine Automation Controller NJ series Database Connection CPU Units User s Manual NJ501 1520 NJ501 1420 NJ501 1320 CPU Unit always in control W527 E1 02 OMRON 2013 All rights reserved No part of this publication may be reproduced stored in a retrieval system or transmitted in any form or by any means mechanical electronic photocopying recording or otherwise without the prior written permission of OMRON No patent liability is assumed with respect to the use of the information contained herein Moreover because OMRON is constantly striving to improve its high quality products the information contained in this manual is subject to change without notice Every precaution has been taken in the preparation of this manual Neverthe less OMRON assumes no responsibility for errors or omissions Neither is any liability assumed for damages resulting from the use of the information contained in this publication Trademarks e Sysmac and SYSMAC are trademarks or registered trademarks of OMRON Corporation in Japan and other countries for OMRON factory automation products e Windows Windows 98 Windows XP Windows Vista and Windows 7 Windows 8 SQL Server and Excel are registered trademarks of Microsoft Corporation in the USA and other countries e EtherCATo is registered trademark and patented technology licensed by Beckhoff Automation GmbH Germany e ODVA CIP CompoNet DeviceNet and Ethe
114. Process The instruction was executed before completion of the DB s processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_Update DB_ Select or DB_Delete instruction NJ series Database Connection CPU Units User s Manual W527 A 15 J W O O 3 5 oO QO O 5 gt a pce c QO O 5 na u suj ga p10094 ga Hasut Appendix A Function This instruction is used to insert the values of the DB Map Variable specified in the MapVar input variable to the table mapped by a DB_CreateMapping instruction as a record When the Spool function is enabled the SQL statement is stored in the Spool memory in the following cases In these cases DBC_SEND_SPOOLEDis set in the SendSiatus output variable and the instruction is terminated due to an error When the values cannot be inserted to the DB due to a network failure or other causes DB Connection Disconnected Error Status When the values cannot be inserted to the DB within the time specified in the TimeOut input variable DB Connection Instruction Execution Timeout When one or more SQL statements are already stored in the Spool memory Data Already Spooled If an instruction error SQL Execution Error occurs when the Spool function is enabled the transmitted SQL statement itself can be the cause of the SQL Execution Error Therefore the SQL statement is not stored in the Spool memory because the SQL
115. Status _DBC_SEND_ COMPLETE The SQL statement is not stored in the Spool memory When executing a DB_Select or DB_Delete instruction Connected ErrorlD 300B hex SQL Execution Error When resending Spool data Connected The SQL statement is not stored in the Spool memory again If an instruction error SQL Execution Error occurs the transmitted SQL statement itself can be the cause of the SQL Execution Error Therefore the SQL statement is not stored in the Spool memory because the SQL Execution Error may occur again when the SQL statement is resent NJ series Database Connection CPU Units User s Manual W527 5 Other Functions 5 4 4 Communications Timeout The communications timeout is monitored in the following cases When sending an SQL statement to a DB using a DB_Insert Insert DB Record DB_Update Update DB Record DB_Select Retrieve DB Record or DB_Delete Delete DB Record instruction oa When resending an SQL statement stored in the Spool memory IN a 3 The following table shows the operation to be performed when a communications timeout has D occurred When the DB Connection Spool Instruction execution result timeout status after the function occurred timeout occurred 2 When executing Disconnected Enabled ErrorlD 3011 hex DB Connection Disconnected Error a a DB_Insert or Status TI DB_Update SendStatus _DBC_SEND_SPOOLED 5 instruction The SQL
116. Status Shutdown system defined variable Shutdown flag of the DB Connection Service Status is TRUE e Checking by executing an instruction Confirm that the Done output variable of the DB_Shutdown Shutdown DB Connection Service instruction is TRUE 5 14 NJ series Database Connection CPU Units User s Manual W527 5 Other Functions 5 3 How to Prevent Losing SQL Statements at Power Interruption This section describes how to write the user program so as not to lose the SQL statements at power interruption 5 3 1 Overview You can prevent losing the SQL statements to send and the SQL statements stored in the Spool memory even if a power interruption occurred during execution of a record processing instruction such as DB_Insert and DB_ Update instructions by using the Spool function in combination with the user program S UBW E S TOS Bulso7 U3A 1d 0 MOH S uodn119 U JBMOd e 5 3 2 Procedures Use the following procedures i Checking the Progress of the DB Connection Instruction The progress of the DB Connection Instructions is output to the SendStatus output variable as a enumeration data Use this data to create the user program 5 Output variable Meaning Data type Description S SendStatus Send _eDBC_SEND_STATUS _DBC_SEND_INIT 0 Initial status a Status _DBC_SEND_UNSENT 1 SQL statement unsent _DBC_SEND_ SENDING 2 Sending SQL statement _DBC_SEND_ SPOOLED 3 SQL statement spooled _DBC_SEND_COMPLETE 4
117. Sysmac Studio You can specify the following comparison unit for the DB Connection Service in the Synchronization Window Synchronization data name Level Number Ee lalce Remarks comparison Host Connection Settings 2 1 Not supported DB Connection 3 1 Not supported DB Connection Service Settings 4 1 Not supported DB Connection Settings 4 1 Not supported The DB Connection settings are reflected when the DB Connection Service is started NJ series Database Connection CPU Units User s Manual W527 3 19 o o U Q Q o 3 3 D gt Q o a o n h oO saiqele Paulyap Wa shS p G E 3 Programming the DB Connection Function 3 6 Debugging in Design Startup and Operation Phases You can use the following debugging procedures according to the phase and actual device environment 3 6 1 Design Phase This section gives the debugging procedure in the design phase Actual device environment Debugging method CPU Unit DB Check item Operation Exist Not exist Checking the executions of DB Start the DB Connection Service in Test Mode or Connection Instructions on the Execute DB Connection Instructions not connected physical CPU Unit Note In Test Mode SQL statements are not sent actually but the processing ends as if they were sent normally Check the Operation Logs i e Execution Log and Debug Log 3 6 2 Startup Phase This section
118. The DB_CreateMapping instruction creates a mapping from a DB Map Variable to a table of a DB Instruction DB_CreateMapping Note The DB_CreateMapping_instance is an instance of DB_CreateMapping instruction which is declared as a variable Name Create DB Map FB FUN FB Graphic expression DB_CreateMapping_instance DB_CreateMapping Execute Done DBConnection Busy TableName Error MapVar ErrorlD SQLType ST expression DB_CreateMapping_instance Execute DBConnection TableName MapVar SQLType Done Busy Error ErrorlD Variables i Input Variables Name Meaning Data type Valid range Unit Default Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition DBConnection DB DWORD 16 00000000 to 16 FFFFFFFF 16 0000 Specify the DB Connection 0000 connection established by a DB_Connect instruction TableName Table STRING Depends on the data type s Specify a table name in Name the DB MapVar DB Map Structure Structure Depends on the data type Specify a structure Variable array entire array variable defined for accessing the DB SQLType SQL Type _eDBC_SQLTYPE DBC_SQLTYPE_INSERT 1 0 Specify a type of SQL INSERT command for the _DBC_SQLTYPE_UPDATE 2 variable to map UPDATE _DBC_SQLTYPE_SELECT 3 SELECT Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE
119. The start processing for inserting DB records is executed when this variable is TRUE DB_CreateMapping_Update_instance DB_CreateMapping Instance of DB_CreateMapping instruction MapVar_Update PRODUCTION_UPD This variable is assigned to the Map Var input ATE variable to DB_CreateMapping_Update_instance DB_Update_instance DB_Update Instance of DB_Update instruction WhereCond STRING 256 This variable is assigned to the Where input variable to DB_CreateMapping_Update_instance Trigger_Update BOOL FALSE Variable used as a trigger for updating DB records LastTrigger_Update BOOL FALSE Variable to retain the trigger status of the previous execution Operating_Update BOOL FALSE The DB_Update instruction is executed when this variable is TRUE OperatingStart_Update BOOL FALSE The start processing for updating DB records is executed when this variable is TRUE A 28 NJ series Database Connection CPU Units User s Manual W527 Appendix A Name Data type Initial value Comment DB_Close_instance DB_ Close Instance of DB_Close instruction Trigger_Close BOOL FALSE Variable used as a trigger for closing the DB Connection LastTrigger_Close BOOL FALSE Variable to retain the trigger status of the previous execution Operating_Close BOOL FALSE The DB_Close instruction is executed when this variable is TRUE OperatingStart_Close BOOL FALSE The start processing for closing the DB Connection i
120. U Units User s Manual W527 3 15 3 Programming the DB Connection Function 3 5 Programming and Transfer This section describes how to program the DB Connection Service DB Connection Instruction set and system defined variables Refer to Sample Programming of each DB Connection Instruction given in Appendix for programming examples 3 5 1 Programming the DB Connection Service Use the following procedure to program the DB Connection Service 1 Select a DB Connection Instruction from the DB Connection instruction category of the Toolbox to the right of the program editor of Sysmac Studio Write the DB Connection Instructions in the following order 1 Write a DB_ControlService Control DB Connection Service when you start the DB Connection Service using the instruction This instruction is not required if the DB Connection Service is automatically started when the operating mode of the CPU Unit is changed to RUN mode 2 Write a DB_Connect Establish DB Connection instruction 3 Write a DB_CreateMapping Create DB Map instruction 4 Write a DB_Insert Insert DB Record DB_Update Update DB Record DB_ Select Retrieve DB Record or other instruction 2 Check the status of the DB Connection Service with a system defined variable The status can be Running in Operation Mode Running in Test Mode Idle Error or Shutdown 3 Transfer the DB Connection settings and user program Transfer the DB Connection settings and user pro
121. Variables 5 Data type Online Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used _EIP_EtnOnlineSta NJ series Database Connection CPU Units User s Manual W527 A 9 Appendix A Related Error Codes Error code Meaning Description 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same Same Time time 3000 hex DB Connection Service not Started The instruction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was Shutting Down shut down or while the DB Connection Service was being shut down 3008 hex Invalid DB Connection The value of the DBConnection input variable is invalid or the specified DB Connection is already closed 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress Function This instruction Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes
122. W506 NJ series Database Connection CPU Units User s Manual W527 5 19 suonoun4 Bunopuoy noawil v G suonouny Bunopuoy noawll L p G 5 Other Functions 5 4 2 Login Timeout The login timeout is monitored in the following cases 5 4 3 5 20 When connecting to a DB using a DB_Connect Establish DB Connection instruction When reconnecting to a DB while a DB Connection is in the Disconnected status The following table shows the operation to be performed when a login timeout has occurred When the timeout occurred DB Connection status after the timeout occurred Instruction execution result When executing a DB_Connect instruction Closed ErrorlD 3005 hex DB Connection Failed When reconnecting to a DB Disconnected Query Execution Timeout The query execution timeout is monitored in the following cases When sending an SQL statement to a DB using a DB_Insert Insert DB Record DB_Update Update DB Record DB_Select Retrieve DB Record or DB_Delete Delete DB Record instruction When resending an SQL statement stored in the Spool memory The following table shows the operation to be performed when a query execution timeout has occurred When the timeout occurred DB Connection status after the timeout occurred Instruction execution result When executing a DB_Insert or DB_Update instruction Connected ErrorlD 300B hex SQL Execution Error Send
123. When two or more DB Connection Instructions are executed for a DB Connection at the same time the DB Connection Service executes the instructions one by one The measurement of timeout for the second and later instructions is started when the instruction is executed by the DB Connection Service not when the Execute input variable is changed to TRUE Therefore the time from when the Execute input variable is changed to TRUE to when the timeout occurs for the instruction is longer than the time set for the timeout An error occurs for this instruction in the following cases Error will be TRUE When the instruction was executed when the DB Connection Service was not running When the instruction was executed while the initialization processing of the DB Connection Service was in progress When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down A 16 NJ series Database Connection CPU Units User s Manual W527 Appendix A When the value of the DBConnection input variable is invalid or the specified DB Connection is already closed When the variable specified in the MapVar input variable has not been mapped by a DB_CreateMapping instruction When the value of the Timeout input variable is outside the valid range When the executed SQL statement resulted in an e
124. _instance Error TRUE THEN Go to the next step when the instruction is not completed within the specified time IF DB_Update_instance ErrorlD 16 3012 THEN Operating_Update FALSE Normal end ELSE Execute the error handler Implement the error handler FaultHandler_Update according to the device FaultHandler_Update Operating_Update FALSE END_IF END_IF END_IF Close the DB Connection MyDB1 Start the sequence when the variable Trigger_Close changes to TRUE IF Trigger_Close TRUE AND LastTrigger_Close FALSE THEN OperatingStart_Close TRUE Operating_Close TRUE END_IF LastTrigger_Close Trigger_Close Sequence start processing IF OperatingStart_Close TRUE THEN Initialize the instance of the applicable DB Connection Instruction DB_Close_instance Execute FALSE O Ww O O 5 5 oO QO O 5 5 D o c QO O 5 D OperatingStart_Close FALSE END_IF Close the DB Connection MyDB1 IF Operating_Close TRUE THEN Close the DB Connection DB_Close_instance Execute TRUE DBConnection MyDB1 IF DB_Close_instance Done TRUE THEN Operating_Close FALSE Normal end END_IF IF DB_Close_instance Error TRUE THEN puodey ga aw pdn spd ga Execute the error handler Program the error handler FaultHandler_Close according to the device FaultHandler_Close Operating_Close FALSE END_IF END_IF NJ series Dat
125. a operation is executed from Sysmac Studio e When the automatic clear condition is met i When the Specified Clear Condition is Met When Auto is selected for Resend Spool Data in the Spool Settings you can set the condition for clearing the SQL statements from the Spool memory for each DB Connection in Clear condition under DB Connection Settings Spool Settings on Sysmac Studio Select from the following options uonoun4 joods G Clear condition Description Do not clear Default The SQL statements stored in the Spool memory are not cleared At power ON The SQL statements are cleared from the Spool memory when the power supply to the CPU Unit is turned ON When DB connection The SQL statements are cleared from the Spool memory when the DB Connection service started Service is started When DB connection The SQL statements are cleared from the Spool memory when the DB Connection is established established i e when the status changes from Closed to Connected If you select this option the SQL statements are cleared from the Spool memory without being resent When a DB_ControlSpool Resend Clear Spool Data Instruction is Executed You can clear the SQL statements from the Spool memory by executing a DB_ControlSpool Resend Clear Spool Data instruction oway joods y WO SJUBWS EIS TOS 24 Bunea 1 S NJ series Database Connection CPU Units User s Manual W527 5 7 5 Other Functions i When the Cle
126. abase Connection CPU Units User s Manual W527 A 33 Appendix A DB_ Select Retrieve DB Record The DB_ Select instruction retrieves records from a table to a DB Map Variable Instruction Name Retrieve DB FB Record DB_ Select FB FUN Sort TimeOut Graphic expression DB_Select_instance DB_Select Execute Done DBConnection Where Busy Error ErrorlD RecCnt SelectedCnt ST expression DB_Select_instance Execute DBConnection Where Sort TimeOut MapVar Done Busy Error ErrorlD RecCnt SelectedCnt Note The DB_Select_instance is an instance of DB_Select instruction which is declared as a variable Variables i Input Variables x Data 7 TPE Name Meaning Me Valid range Unit Default Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition DBConnection DB Connection DWORD 16 00000000 to 16 0000 Specify the DB Connection established 16 FFFFFFFF 0000 by a DB_Connect instruction Where Retrieval STRING 1 986 bytes max r Specify a text string that expresses Conditions including the final retrieval conditions WHERE clause NULL character WHERE is not included Sort Sort Conditions STRING 1 986 bytes max z Specify a text string that expresses sort including the final conditions ORDER BY clause NULL character ORDER BY is not included TimeOut Timeout TIME T 0s T 0s S
127. able 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same Same Time time 3000 hex DB Connection Service not Started The Resend Spool Data operation was executed by this instruction when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was Shutting Down shut down or while the DB Connection Service was being shut down 3008 hex Invalid DB Connection The value of the DBConnection input variable is invalid or the specified DB Connection is already closed 3011 hex DB Connection Disconnected Error Status The DB Connection Service cannot communicate with the DB due to a network failure or other causes 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress Function This instruction is used to resend or clear the SQL statements stored in the Spool memory for the DB Connection specified in the DBConnection input variable When you select manual resend for Spool data the SQL statements stored in the Spool memory are resent by executing this instruction Precautions for Correct Use e Execution of this instruction is continued until processing is completed even if the value of
128. able Products This manual covers the following products e NJ series Database Connection CPU Units e NJ501 1520 e NJ501 1420 e NJ501 1320 e Sysmac Studio e SYSMAC SE2 Version 1 06 or higher NJ series Database Connection CPU Units User s Manual W527 1 Relevant Manuals Relevant Manuals There are three manuals that provide basic information on the NJ series CPU Units the NU series CPU Unit Hardware User s Manual Cat No W500 the NJ series CPU Unit Software User s Manual Cat No W501 and the NU series Instructions Reference Manual Cat No W502 Most operations are performed from Sysmac Studio Automation Software Refer to the Sysmac Studio Version 1 Operation Manual Cat No W504 for information on Sysmac Studio Other manuals are necessary for specific system configurations and applications Read all of the manuals that are relevant to your system configuration and application to make the most of the NJ series CPU Unit NJ series User s Manuals Basic information NJ series CPU Unit Hardware User s Manual Nu series CPU Unit Software User s Manual NJ series Instructions Reference Manual NJ series CPU Unit Motion Control User s Manual NJ series CPU Unit Built in EtherCAT Port User s Manual NJ series Motion Control Instructions Reference Manual NJ series CPU Unit Built in EtherNet IP Port User s Manual NJ series Database Connection CPU Units User s Manual NJ ser
129. able was temporarily locked Countermeasures Measure the processing time in the DB in reference to B 2 3 How to Measure DB Response Time Identify the cause based on the timing when the processing time got longer in the DB and take a countermeasure in the server B 2 2 Impact of Operation Log Recording on Execution Time of DB Connection Instructions When the Operation Logs are recorded execution time of DB Connection Instructions i e DB_Insert DB_Update DB_Select and DB_Delete instructions gets longer The following table gives the reference values for increased execution time of DB Connection Instructions while the Operation Logs are recorded Confirm that the equipment will not be adversely affected before starting recording to the Operation Logs Log type Instruction Reference value for Measurement condition increase in instruction execution time Execution Log DB_Insert 1 4ms When executing an INSERT operation for 100 column record Debug Log DB_Insert 3 3 ms When executing an INSERT operation for 100 column record Percentage of task execution time 50 B 8 NJ series Database Connection CPU Units User s Manual W527 Appendix B B 2 3 How to Measure DB Response Time The DB response time refers to the time since an SQL statement is sent from the CPU Unit until the SQL execution result is returned from the DB You can find the DB response time by executing a DB_GetConnectionStatus instruction after e
130. ails Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None ae oo Cause and Assumed cause Correction Prevention correction Though Execution Log was Enable the Execution Log in the Execute the instruction when the specified in the LogType input DB Connection Service settings Execution Log is enabled variable the Execution Log is disabled Though Debug Log was Start recording to the Debug Log Execute the instruction after the specified in the LogType input using a DB_ControlService recording to the Debug Log is variable recording to the Debug instruction Or start recording to started Log is stopped the Debug Log from Sysmac Studio Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527
131. al W527 7 Troubleshooting Event name DB Connection Already Established Event code 5401 3006 hex Meaning A same name DB Connection is already established Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction The relevant instruction was Correct the user program so that Write the user program so that the executed when a same name the relevant instruction is executed relevant instruction is executed DB Connection was already when the DB Connection is closed when the DB Connection is closed established Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None
132. and select Online Settings from the menu The following Online Settings Tab Page is displayed ial Service Shutdown Shutdown Y Debug Log Start Stop Stop Start Stop a SSS ee You can start and stop recording to the Debug Log by clicking the following buttons Category Item Button Operation Debug Log Start Stop Start Recording to the Debug Log is started Stop Recording to the Debug Log is stopped 2 Click the Stop Button A confirmation message is displayed PPLA TEN ENIA 3 Click the Yes Button i Stop by executing a DB_ControlService Instruction Specify Finish recording to Debug Log in the Cmd input variable of the DB_ControlService Control DB Connection Service instruction and execute the instruction Refer to Appendix DB Connection Instructions for details of the instruction l Automatically Stopped when a Condition is Met The recording to Debug Log is automatically stopped in the following conditions When the SD Memory Card power supply switch is pressed e When the Synchronization download operation is executed on Sysmac Studio When the Clear All Memory operation is executed When the Restore operation of the SD Memory Card backup function or Sysmac Studio Controller backup function is executed NJ series Database Connection CPU Units User s Manual W527 6 13 i do iw o a Ko O a 607 Bngaq 0 Buip oo y Buiddojs 9 6 How
133. ar Spool Data operation is executed from Sysmac Studio You can clear the SQL statements from the Spool memory by the following operation from Sysmac Studio 1 Right click a DB Connection in the Multiview Explorer and select Clear Spool Data from the menu while online with an NJ series CPU Unit Clear Spool Data The following message is displayed 4 my Are you sure to clear the spool data in the controller Y N Yes J No 2 Click the Yes Button When the automatic clear condition is met The SQL statements are automatically cleared from the Spool memory regardless of the Resend spool data setting in the following cases e When you change the DB Connection settings and execute the Synchronization download operation on Sysmac Studio e When you execute the Clear All Memory operation e When a Battery backup Memory Check Error occurred When you execute the Restore operation of the SD Memory Card backup function or Sysmac Studio Controller backup function When you restore the memory using the Restore Variables Memory function of Sysmac Studio 5 8 NJ series Database Connection CPU Units User s Manual W527 5 Other Functions 5 1 8 Relationship with the DB Connection Instructions This section describes the operations of DB Connection Instructions to be performed when one or more SQL statements are already stored in the Spool memory and the impacts to the spooling operations to be performed when an Instru
134. art the DB Connection Service Click the Start Operation Mode or Start Test Mode Button To stop the DB Connection Service Click the Stop Button A confirmation message is displayed The following is an example dialog box to be displayed when starting the DB Connection Service in Operation Mode 3 Click the Yes Button Note You can start or stop the DB Connection Service regardless of the operating mode of the CPU Unit EN Additional Information You can shut down the DB Connection Service by clicking the Shutdown Button Refer to 5 2 DB Connection Service Shutdown Function for details Executing a DB_ControlService Control DB Connection Service Instruction Specify one of the following commands in the Cmd input variable of the DB_ControlService Control DB Connection Service instruction Start the service in Operation Mode Start the service in Test Mode Stop the service Refer to Appendix DB Connection Instructions for details of the DB_ControlService Control DB Connection Service instruction DB Connection Service is Stopped or Cannot be Started In the following conditions the DB Connection Service cannot be started or the service is stopped DB Connection Service cannot be Started The DB Connection Service cannot be started in the following cases When the DB Connection Service settings are invalid e When the operation status of the DB Connection Service is Initializing e When the operation sta
135. as executed when the DB Connection Service was not running When the instruction was executed while the initialization processing of the DB Connection Service was in progress When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down When the DB Connection name specified in the DBConnectionName input variable is not set in any DB Connection Settings When the DBConnectionName input variable is a text string consisting of NULL characters 16 00 only When a space character is included in the text string specified for the DBConnectionName input variable When the DBConnectionName input variable does not end in NULL When the connection could not be established because the address set in the DB Connection Settings was wrong When the DB set in the DB Connection Settings rejected the connection When the DB Connection Service cannot communicate with the DB due to a network failure or other causes When a same name DB Connection is already established When the maximum number of connections that can be established at the same time is exceeded When 32 or more DB Connection Instructions were executed at the same time Sample Programming Refer to the sample programming that is provided for the DB_Update instruction A 8 NJ series Database Connection CPU Units
136. ase Connection CPU Units User s Manual W527 19 Regulations and Standards 20 SUPPORT SERVICES Because this software is as is we may not provide support services for it ENTIRE AGREEMENT This agreement and the terms for supplements updates Internet based services and support services that you use are the entire agreement for the software and support services APPLICABLE LAW United States If you acquired the software in the United States Washington state law governs the interpretation of this agreement and applies to claims for breach of it regardless of conflict of laws principles The laws of the state where you live govern all other claims including claims under state consumer protection laws unfair competition laws and in tort Outside the United States If you acquired the software in any other country the laws of that country apply LEGAL EFFECT This agreement describes certain legal rights You may have other rights under the laws of your country You may also have rights with respect to the party from whom you acquired the software This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so DISCLAIMER OF WARRANTY THE SOFTWARE IS LICENSED AS IS YOU BEAR THE RISK OF USING IT MICROSOFT GIVES NO EXPRESS WARRANTIES GUARANTEES OR CONDITIONS YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHAN
137. ata type Initial value Comment _DBC_Status _sDBC_STATUS System defined variable that shows the status of the DB Connection Service DB_Connect_instance DB_Connect Instance of DB_Connect instruction MyDB1 DWORD a This variable is assigned to the DBConnection output variable from DB_Connect_instance LotNo UINT 1234 Variable to specify the lot number for retrieving deleting DB records Trigger_Connect BOOL FALSE Variable used as a trigger for establishing a DB Connection RS_Connect_instance RS Instance of RS instruction Operating _Connect BOOL FALSE The DB_Connect instruction is executed when this variable is TRUE OperatingEnd_Connect BOOL FALSE This variable changes to TRUE when the DB_Connect instruction is completed DB_CreateMapping_Select_instance DB_CreateMapping Instance of DB_CreateMapping instruction A 42 NJ series Database Connection CPU Units User s Manual W527 Appendix A Name Data type Initial value Comment MapVar_Select ARRAY 0 9 OF This variable is assigned to the MapVar input PRODUCTION_SELECT variable to DB_CreateMapping_Select_instance WhereCond_Select STRING 256 This variable is assigned to the Where input variable to DB_Select_instance SortCond_Select STRING 256 This variable is assigned to the Sort input variable to DB_Select_instance DB_Select_instance DB_Select Instance of DB_Select instruc
138. attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None ae Cause and Assumed cause Correction Prevention correction A command to start the DB Start the DB Connection Service Write the user program so that the Connection Service was not Or correct the user program so relevant instruction is executed given before the execution of that the relevant instruction is while the DB Connection Service is relevant instruction executed while the DB Connection running A command to stop the DB Service is running Connection Service was given before the execution of relevant instruction Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions Remarks None NJ series Database Connection CPU Units User s Manual W527 7 23 Bee Guloouse qnol 2 2 suondnos q 10113 2 2 2 7 Troubleshooting
139. benassccteseneanes 4 12 Disconnection date time ccceeecceceseceeeeneeceenteeeeneeees 4 12 Displaying DB Connection Instructions on Sysmac Studio ceccesccessceecsseceesseeecessseeceseceens 3 17 EM At arcsie cerier e iiai EE i Error code Error MESSARE naeron eine n ispi E Erro Sres r a E e Er aeS z Establishing Closing a DB Connection NJ series Database Connection CPU Units User s Manual W527 EVO CO Coes cccieccucvesseds cdencesecnvoncdvcceades oecesedscdendenesenes 7 8 7 10 Event name o ceccccesesscccceceeseseceeeceesesseaeeeceeseeseaeeees 7 8 7 10 Execution POterio aeri eeraa aaraa eari A 29 2 5 Execution Log Save Failed ccccccesceeeseeeseeeeeeeeeeeeee 7 17 How to Create a Structure Data Type for DB Access 3 6 How to Prevent Losing SQL Statements at Power Tniterription vevcisec esntirerciies n a i 5 15 INSERT operationen arn a A 1 4 Instruction Execution Timeout sssssseesseeserssserrserreee 5 21 Invalid DB Connection s sesessseessesererrsresressrssrrsrreree 7 28 Invalid DB Connection Name cccceceeeseeseeeseeeteeesees 7 25 Invalid DB Map Variable eeceeeceeeceeseeeeeeseeeeeeeees 7 29 Invalid Extraction Condition cccccccccesseeseeeeeeeeees 7 33 IP address nunes vein E T S 2 8 Keep Alive Monitoring Time sssssssssssssssessseserssreeesrreesee 5 21 Log Code Out of Range ccccccccccceccesceesceesteesteeeteeeenees 7 34 Login
140. ccecceeeeeeeeeeeeeeeeeeeeeeeeeeeseeeeseaeeeeneeeeaes 6 11 6 3 4 Starting Recording to Debug Log ccceeteeeeseeteeeeeeeeeeeeneeeeees 6 12 6 3 5 Stopping Recording to Debug Log sssssesssesesresrrssrrssirnesrnssnsens 6 13 6 3 6 Checking the Debug Log s sssessssesssessressnnernnstnnssnnssrnssnnesrnssrnsens 6 14 6 3 7 Debug Log File Specifications ccceccccceeeeeneeceeeeeeeteeeesaeeneneees 6 14 6 4 SQL Execution Failure Log eeeeccceecescceeeceeeceeeeseaeeeeeseaeeeeesneeeeseseaeeenens 6 18 6 4 1 OE A AA T A E A 6 18 6 4 2 Application Procedures aurera a a EEan ERA E KAEN ER KERNER 6 18 6 4 3 Setting the SQL Execution Failure Log csscceeeseeesteeeeseeteees 6 18 6 4 4 Checking the SQL Execution Failure Log s s s 6 19 6 4 5 SQL Execution Failure Log File Specifications ccceeeeeee 6 19 6 5 SD Memory Card Operations ccccceceeeeeeeeeneeeeeeeneeeeeeeneaeeeeeseaeeeeseneeeee 6 22 6 5 1 Saving Operation Log Files on SD Memory Card s s 6 22 6 5 2 Directory Used for DB Connection Service ccceeseeeesteeeees 6 22 6 5 3 Operation Log Operations in Replacing the SD Memory Card 6 23 6 5 4 Replacement Timing of SD Memory Catd ceecceeeteeseeeeeeees 6 23 6 6 Checking the Operation LOGS 00 0 eee ceeeeeeeeene eter eeneeeeeeeneaeeeeesaeeeeteaeeeees 6 24 6 6 1 How to Check the Operation LOGS ccceceeeeeeeeeceeeeeeeeeseeeeeenees 6 24 6 6 2 Checking the Log on t
141. ccording to specifications System defined Variable Data type Name variables None see Cause and Assumed cause Correction Prevention correction The DB Connection Name Specify a correct DB Connection Confirm that a DB Connection specified in the Name in the DBConnectionName Name is correctly specified in the DBConnectionName input input variable of the relevant DBConnectionName input variable variable of the relevant instruction of the relevant instruction instruction is wrong The DB Connection Name setin Specify a correct DB Connection Confirm that a DB Connection the DB Connection settings is Name in the DB Connection Name is correctly set in the DB wrong settings Connection Settings Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 25 Be Guoouse qnos 2 2 suondnos q 10113 2 2 2 7 Troubleshooting
142. cessing of Spool data is completed RS_instance RS Instance of RS instruction MyStatus _sDBC_CONNECTION_STATUS This variable is assigned to the ConnectionStatus output variable from DB_GetConnectionStatus_instance Resend BOOL FALSE This variable changes to TRUE when the status of the DB Connection is Connected 0 im Q O 2 io xe O o D D n D 2 lt oO je 02 pe O oO O je 2 Nosent BOOL FALSE This variable changes to TRUE when the status of the DB Connection is not Connected ControlSpool_OK BOOL FALSE This variable changes to TRUE when the DB_ControlSpool instruction is completed normally NJ series Database Connection CPU Units User s Manual W527 A 73 Appendix A Sample Programming Resend the SQL statements stored in the Spool memory when the status of the DB Connection is Connected Check the completion of the instruction Nosent OperatingEnd DB_GetConnectionStatus_instance Error DB_ControlSpool_instance Done DB_ControlSpool_instance Error Accept the trigger RS_instance Trigger Operating RS _ t Set Q1 OperatingEnd Reset1 Get the status of the DB Connection DB_GetConnectionStatus_instance Operating DB_GetConnectionStatus Execute Done MyDatabaset DBConnectionName Busy Error ErrorlD ConnectionStatus MyStatus When the instructio
143. cessing of the DB Connection Service was in progress e When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down e When the value of the DBConnection input variable is invalid or the specified DB Connection is already closed When a value that is not defined as an enumerator was specified in the Cmd input variable When the DB Connection Service cannot communicate with the DB due to a network failure or other causes When 32 or more DB Connection Instructions were executed at the same time Sample Programming This section gives sample programming for resending the SQL statements stored in the Spool memory if the status of the DB Connection is Connected when the trigger variable changes to TRUE l Ladder Diagram Main Variables suonon suj uonosuuo gq Name Data type Initial value Comment DB_GetConnectionStatus_instance DB_GetConnectionStatus Instance of DB_GetConnectionStatus instruction DB_ControlSpool_instance DB_ControlSpool Instance of DB_ControlSpool instruction Trigger BOOL FALSE Variable used as a trigger for resending the Spool data Operating BOOL FALSE When this variable is TRUE the resending processing of Spool data is executed if necessary OperatingEnd BOOL FALSE This variable changes to TRUE when the resending pro
144. changed or when significant construction changes are made However some specifications of the Product may be changed without any notice When in doubt special part numbers may be assigned to fix or establish key specifications for your application Please consult with your Omron s representative at any time to confirm actual specifications of purchased Product NJ series Database Connection CPU Units User s Manual W527 Terms and Conditions Agreement i Errors and Omissions Information presented by Omron Companies has been checked and is believed to be accurate however no responsibility is assumed for clerical typographical or proofreading errors or omissions NJ series Database Connection CPU Units User s Manual W527 13 Safety Precautions Safety Precautions Refer to the following manuals for safety precautions e NJ series CPU Unit Hardware User s Manual Cat No W500 e NJ series CPU Unit Software User s Manual Cat No W501 e Sysmac Studio Version 1 Operation Manual Cat No W504 Definition of Precautionary Information 14 The following notation is used in this manual to provide precautions required to ensure safe usage of the NJ series DB Connection Service function The safety precautions that are provided are extremely important to safety Always read and heed the information provided in all safety precautions The following notation is used D recautions for Safe Use Indicates precautions on what t
145. cluded in the text string specified for the DBConnectionName input variable The DBConnectionName input variable does not end in NULL 041D hex Too Many Instructions Executed at 32 or more DB Connection Instructions were executed at the same time the Same Time 3000 hex DB Connection Service not Started The instruction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was shut down or Shutting Down while the DB Connection Service was being shut down 3003 hex Invalid DB Connection Name The DB Connection name specified in the DBConnectionName input variable is not set in any DB Connection Settings 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress Function This instruction is used to get the status of the DB Connection specified in the DBConnection input variable The current status is output to the ConnectionStatus output variable Refer to the m ServiceStatus of A 1 2 Variables Used in the DB Connection Instructions for the status Precautions for Correct Use e of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or
146. cording to the data type and character code in the DB In NJ Series text strings are handled as UTF 8 One byte is used for each single byte alphanumeric character and multiple bytes are used for each multi byte character Three bytes are used for each Japanese character as a guide 2 Integer in units of nanoseconds SQL Server Data type gt A Data type in DB Data type in NJ series Controllers category Exact numeric bigint LINT UDINT TIME bit BOOL decimal ULINT int DINT UINT money LREAL numeric ULINT smallint INT USINT smallmoney REAL tinyint USINT Approximate float LREAL numeric real REAL Date and time date DATE datetime2 DATE_AND_TIME datetime DATE_AND_TIME datetimeoffset DATE_AND_TIME smalldatetime DATE_AND_TIME time TIME_OF_DAY String char STRING text STRING varchar STRING nchar STRING ntext STRING nvarchar STRING Binary binary None image None varbinary None Others cursor None NJ series Database Connection CPU Units User s Manual W527 p N Q oO je Q w ep G Q G oO O je w lt O i gt sseooy qq 104 edA gq eunjonis Jo suoleoiosds Z Z 3 Programming the DB Connection Function Data lyke Data type in DB Data type in NJ series Controllers category hierarchyid None sql_variant None
147. cords sorted by the values of two columns Sort the values of ColumnA in ascending order and values of ColumnB in descending order ColumnA ASC ColumnB DESC SQL statement to create SELECT FROM TableProduct ORDER BY ColumnA ASC ColumnB DESC Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur This instruction cannot be executed without specifying the retrieval conditions When no record is retrieved as the execution result of this instruction the values of the RecCnt and SelectedCnt output variables are both 0 and the instruction is normally completed Even if the number of array elements of the DB Map Variable does not match the number of retrieved records as the execution result of this instruction the instruction is also normally completed When the DB Connection Service was started in Test Mode this instruction is normally ended without executing the SELECT operation for the DB actually No values are stored in the
148. ction Execution Timeout occurred for a DB Connection Instruction Executing DB Connection Instructions when SQL Statements are Already Stored in the Spool Memory This section describes the operation to be performed when each DB Connection Instruction is executed for a DB Connection that already has one or more SQL statements in the Spool A memory 4 Instruction Operation o DB_Insert The SQL statement INSERT is spooled Q Insert DB The instruction ends in an error Error TRUE SendStatus _DBC_SEND_SPOOLED T Record Refer to Appendix DB Connection Instructions for ErrorID of the instruction execution error DB_Update The SQL statement UPDATE is spooled Q Update DB The instruction ends in an error Error TRUE SendStatus _DBC_SEND_SPOOLED o Record Refer to Appendix DB Connection Instructions for ErrorID of the instruction execution error DB_Select The SQL statement SELECT is not sent to the DB Retrieve DB An instruction execution error occurs Error TRUE Record Refer to Appendix DB Connection Instructions for ErrorID of the instruction execution error DB_Delete The SQL statement DELETE is not sent to the DB Delete DB An instruction execution error occurs Error TRUE Record Refer to Appendix DB Connection Instructions for ErrorID of the instruction execution error Ifthe remaining Spool memory area is not enough when the SQL statement is spooled the SQL statements will be di
149. ction Service Started ccceeceesceseeeeteeeees 7 21 DB Connection Service Status cccccccesccesceseceeseeeeees 3 19 DB Connection Service Stopped cecceessceseeeereeees 7 21 DB Connection Setting EVror ce eeeeseeseeeecereeteeeeeeees 7 19 l 2 DB Connection settings cecececseeseeseeseeeceeeceeeeneeeneens 2 4 DB Connection Settings ccceccsesseeseeeteeeeesteeeeeneeeeeens 2 7 DB Connection System ccccccccecseecseeceeeceseceseceneeenseeesee 1 6 DB in PLOCOSS side ves aie tess a S 7 37 DB Map Variable si iceek athena deena A 29 DB Map Variables and DB Mapping ce eeeeeeeeeeeee 3 9 DBmMappinig steven ce chess iceiehsdieeaseeieawnen gs A 29 3 2 DB Close irene tats cities sanalsateaes i HOS 3 18 DB Close Close DB Connection c ccccceescesesesseseesseeseees 9 DB Confetti senvsesecducsvdassiociusss saebecvoeves 3 18 DB _ Connect Establish DB Connection cccceeeeeee 6 DB_ControlService ccccccccccsssssecccccesssssssecceessesssseseeesees 3 18 DB _ControlService Control DB Connection Service 55 DB_ControlService Control DB Connection Service Instruction nere eri e AE ERE A 4 4 DB ControlS pool wives vccacisiyisl soe desvisies i S 3 18 DB_ControlSpool Resend Clear Spool Data 06 72 DB_ControlSpool Resend Clear Spool Data Instructio seoste e E aia 5 6 5 7 DB_CreateMapping seesssesesesesesessreeresrreeeeee 3 2 3 12 3 18 DB_CreateMapping C
150. ction Service is executed when this variable is TRUE OperatingStart BOOL FALSE The initialization processing is executed when this variable is TRUE ShutdownOK BOOL FALSE This variable changes to TRUE when the DB_ Shutdown instruction is completed normally A 86 NJ series Database Connection CPU Units User s Manual W527 Sample Programming Start the sequence when the variable Trigger changes to TRUE IF Trigger TRUE AND LastTrigger FALSE THEN OperatingStart TRUE Operating TRUE END_IF LastTrigger Trigger Sequence start processing IF OperatingStart TRUE THEN Initialize the instruction instance DB_Shutdown_instance Execute FALSE OperatingStart FALSE END_IF IF Operating TRUE THEN Shut down the DB Connection Service DB_Shutdown_instance Execute TRUE IF DB_Shutdown_instance Done TRUE THEN Normal end processing ShutdownOK TRUE Operating FALSE END_IF IF DB_Shutdown_instance Error TRUE THEN Error handler Operating FALSE END_IF END_IF NJ series Database Connection CPU Units User s Manual W527 Appendix A A 87 suonon suj uonosuuon gq J WO op gt Q O z 891IM8S uoosuuo Gq UMOpPINUS Appendix A A 88 NJ series Database Connection CPU Units User s Manual W527 Appendix B es B 1 Task Design Procedure cccccceecesecceeeeeneceeseseaeeesensaeeneessaeeeesesnansenee
151. cuted SQL statement resulted in an error in the DB When the DB Connection Service cannot communicate with the DB due to a network failure or other causes When one or more SQL statements are already stored in the Spool memory When the instruction was not completed within the time specified in the TimeOut input variable NJ series Database Connection CPU Units User s Manual W527 A 41 Appendix A When the instruction was executed before completion of the DB s processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_ Update DB_ Select or DB_ Delete instruction When 32 or more DB Connection Instructions were executed at the same time Sample Programming This section gives sample programming of the following operations for Oracle database Retrieve production data for the specified lot number from a DB table when the trigger variable changes to TRUE Delete the records other than the latest one if more than one record was retrieved i DB Connection Settings and Data Type Definition The minimum settings necessary for the sample programming are shown below DB Connection Settings DB Connection name MyDatabase1 Structure Data Type Definition Name Data type PRODUCTION_SELECT STRUCT Name STRING 256 LotNo STRING 32 Status STRING 8 ProductionDate DATE FinishTime DATE_AND_TIME f Ladder Diagram Main Variables Name D
152. cution Error may occur again when the SQL statement is resent SUOIPUOD uonnoaxg BHuljoods pue suononysuj sjqeolddy 9 NJ series Database Connection CPU Units User s Manual W527 5 3 5 Other Functions 5 1 4 Memory Area Used by the Spool Function 5 4 The following memory area is used by the Spool function Memory area Description EM Area The unsent SQL statements are stored Total capacity of Spool memory 1 MB max in the following EM Area Spool capacity for each DB Connection 16 EM banks from No 9 hex to 18 hex Total capacity is equally divided by DB Connections for which the Spool function is enabled You can prevent losing the Spool data even if a power interruption occurred in the CPU Unit because the EM Area is non volatile memory La Precautions for Correct Use e When the Spool function is enabled the DB Connection Service uses EM Bank No 9 to 18 Please design the system so that EM Bank No 9 to 18 are not used for the following purposes because the Spool data is corrupted if used AT specification of user defined variables 1 O memory address specification of tags for tag data link e Access by communications commands Access from HMI Specification of Expansion Area words allocated to Special Units for CJ series Special Units The data values in the EM Area are retained by a battery If the battery is not mounted or weak the CPU Unit detects a Battery backup Memory
153. cution of DB_Insert DB_Update DB_ Select Variable or DB_Delete instruction Displays the same ID as the serial ID displayed for the SQL category records in the Execution Log Decimal code consisting of 10 digits max Possible range 0 to 2147483647 When this value exceeds 2147483647 or when the power supply to the CPU Unit is turned ON the value returns to 0 When the category is DB Connection Service DB Connection or User specified Log nothing is displayed Details Variable Displays the details of the Debug Log The contents differ according to the category In the Details parameter information items are separated from each other by a tab Category DB Connection DB type lt tab gt Connection text string lt tab gt User name lt tab gt DB error code lt tab gt Error message DB error code Error code that is specific to DB vendor of the device to connect When a network error has occurred 0 is displayed for DB error code in some cases When 0 is displayed check the Result p co J ey Cc Ko Q Ke parameter Category SQL Table name lt tab gt DB Map Variable name lt tab gt SQL statement DB Map Variable name The POU instance name is not displayed Category SQL Execution Result Table name lt tab gt DB Map Variable name lt tab gt DB response time lt tab gt DB error code lt tab gt Error message DB Map Variable name The POU instance name is not displayed DB response time An
154. d Action not required 6 Data spooled After the SQL statement is spooled when spooling is enabled _DBC_SEND_SPOOLED SQL statement spooled Resend by Spool function auto resend or manual resend NJ series Database Connection CPU Units User s Manual W527 5 Other Functions Resend Flow by User Program Write the user program to re execute the instruction that is being executed at the time of power interruption The resend flow differs by whether a DB_Insert or DB_Update instruction is being executed at the time of power interruption When a DB Insert instruction is being executed START J YES y Read output parameters of Busy NO and SendStatus output variables 1st cycle of the operation values of output parameters of Busy and SendStatus output variables S UBWEIEIS JOS Bulso7 U9A Id 0 MOH E G uondn113 U 19MOd e Busy TRUE and SendStatus _DBC_SEND_SENDING Resend processing required Others Resend processing not required Change the output parameters of Busy and SendStatus output variables to initial values Resend processing required SOINPSDO1d Z E S Establish a DB Connection DB_Connect instruction Vv Create a DB Map Variable for DB record check DB_CreateMapping instruction Retrieve records from the DB using
155. d Function This instruction is used to put a user specified record into the Execution Log or Debug Log Specify whether to record in the Execution Log or Debug Log in the LogType input variable You can record any log code and log message into an Operation Log by specifying the LogCode and LogMsg input variables in the user program The log record format is shown below Serial number lt tab gt Time lt tab gt Category lt tab gt Code lt tab gt Log name lt tab gt Result lt tab gt Details lt CR gt lt LF gt Serial number A serial number from 0 to 65535 The value returns to 0 after 65535 Nothing is output for a text string consisting of NULL characters 16 00 only Text string of log name specified in the LogName input variable Nothing is output for a text string consisting of NULL characters 16 00 only Time Time when the instruction is executed Category Always USER Code Value of log code specified in the LogCode input variable Log name Result Always 0x0000 Details Text string of log message specified in the LogMsg input variable Precautions for Correct Use e Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing e Refer to Using this Section of the NJ seri
156. d at the same Same Time time 3000 hex DB Connection Service not Started The instruction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was Shutting Down shut down or while the DB Connection Service was being shut down 3008 hex Invalid DB Connection The value of the DBConnection input variable is invalid or the specified DB Connection is already closed 3009 hex Invalid DB Map Variable The data type of the variable specified in the MapVar input variable is not a structure Aderivative data type is included as a member of the structure variable specified in the MapVar input variable The DB Map Variable specified in the MapVar input variable is a structure array though INSERT or UPDATE is specified for the SQL Type 3011 hex DB Connection Disconnected Error Status The DB Connection Service cannot communicate with the DB due to a network failure or other causes 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress Function This instruction is used to map the table specified in the TableName input variable with a DB Map Variable specified in the MapVar input variable You need to execute this instruct
157. d in a column gt 2 y Oo name of the table you cannot create the mapping You need to change the column name of the 2 lt table 2 z Example gt 0 Oo When acolumn name is P_Code D DI oO a Tablet 3 3 Because you cannot use a text string aa Name LotNo TotalCount that starts with P_ for a structure member name you cannot create the mapping Refer to Precautions for Correct Use Restrictions on Table s Column Names of 3 2 2 Specifications of Structure Data Type for DB Access for the characters that cannot be specified for structure member names Restrictions on Mapping to Multiple Tables You cannot map the members of a DB Map Variable to columns of different tables Example Structure data type definition used by a DB Table oo To wo wo oO n i is O n O J W je Ke Q Map Variable Vv Table1and2 TotalCount Name STRING 256 LotNo UINT TotalCount UINT Table2 Pcode UINT LotNo Location Producer Location STRING 256 Producer STRING 256 You cannot map structure members to multiple tables Restrictions on Mapping to Multiple Tables You cannot map a DB Map Variable to two or more tables If you execute multiple DB_CreateMapping Create DB Map instructions so as to map a single DB Map Variable to two or more tables the mapping made by the last
158. d party software The license and copyright information associated with this software is available at http Awww fa omron co jp nj_info_e By using this product you will be considered as having accepted the following license conditions If you do not accept the license conditions do not use this product MICROSOFT SOFTWARE LICENSE TERMS REDISTRIBUTION LICENSE FOR MICROSOFT JDBC DRIVER 4 0 FOR SQL SERVER These license terms are an agreement between Microsoft Corporation or based on where you live one of its affiliates and you Please read them They apply to the software named above which includes the media on which you received it if any The terms also apply to any Microsoft updates supplements Internet based services and support services for this software unless other terms accompany those items If so those terms apply BY USING THE SOFTWARE YOU ACCEPT THESE TERMS IF YOU DO NOT ACCEPT THEM DO NOT USE THE SOFTWARE If you comply with these license terms you have the rights below INSTALLATION AND USE RIGHTS You may install and use any number of copies of the software on your devices You may also install the software in a hosted environment ADDITIONAL LICENSING REQUIREMENTS AND OR USE RIGHTS NJ series Database Connection CPU Units User s Manual W527 Regulations and Standards Distributable Code i Right to Use and Distribute You are permitted to distribute the software in programs you develop i
159. d when the instruction is executed by the DB Connection Service not when the Execute input variable is changed to TRUE Therefore the time from when the Execute input variable is changed to TRUE to when the timeout occurs for the instruction is longer than the time set for the timeout J W O O 3 5 oO QO O 5 gt 7 2 c QO O 3 na An error occurs for this instruction in the following cases Error will be TRUE B When the instruction was executed when the DB Connection Service was not running F When the instruction was executed while the initialization processing of the DB Connection Service was in progress G When the instruction was executed while the DB Connection Service was stopped due to an error 2 When the instruction was executed after the DB Connection Service was shut down or while the DB e Connection Service was being shut down w When the value of the DBConnection input variable is invalid or the specified DB Connection is already closed S When the TableName input variable is a text string consisting of NULL characters 16 00 only When a space character is included in the text string specified for the TableName input variable When the Where input variable is a text string consisting of NULL characters 16 00 only When the value of the Timeout input variable is outside the valid range When a value that is over T 180s was specified in the TimeOut input variable When the exe
160. d while Connection Service is commanded the DB Connection Service was Stop the DB Connection Service being stopped after completion of the DB_Insert DB_Update DB_ Select or DB_Delete instruction Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks 7 24 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name DB Connection Service Shutdown or Shutting Event code 5401 3002 hex Down Meaning The DB Connection Service is already shut down or being shut down Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None mes Cause and Assumed cause Correction Prevention correction T
161. ded Invalid Extraction Condition Log Code Out of Range DB Connection Disconnected Error Status DB Connection Instruction Execution Timeout DB Connection Service Error Stop Data Already Spooled DB Connection Service Initializing DB in Process Operation Log Disabled Information None 7 6 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting 7 2 Troubleshooting This section describes the errors that can occur in the DB Connection Service and the corrections for them 7 2 1 Error Table The errors i e events that can occur in the DB Connection Service and DB Connection Instructions are given on the following pages The following abbreviations and symbols are used in the event level column Abbreviation Name Maj Major fault level Prt Partial fault level Min Minor fault level Obs Observation Info Information N N Symbol Meaning 4 S Event levels that are defined by the system S U Event levels that can be changed by the user o This symbol appears only for events for which the user can change the event level 8 gt O Q Refer to the NJ series Troubleshooting Manual Cat No W503 for all NJ series event codes a 7 a Pe m a re a D NJ series Database Connection CPU Units User s Manual W527 7 7 7 Troubleshooting Errors Related to DB Connection Service Event code Event name Meaning As
162. down a c The DB Connections are closed d The Operation Log files Execution Log files Debug Log files and SQL Execution Failure Log files a are stored in the SD Memory Card 2 a 5 2 3 How to Execute the Shutdown Function g 3 You can use the following procedure to execute the shutdown function Sysmac Studio operation Instruction execution i Sysmac Studio Operation Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Online Settings from the menu while online with an NJ series CPU Unit Then click the Shutdown Button under Service Shutdown in the Online Settings Tab Page A Configurations and Setup AQ Service Start Stop Shutdown Shutdown lv Debug Log Start Stop a ask Bi NJ series Database Connection CPU Units User s Manual W527 5 13 5 Other Functions ES Additional Information When you execute the Reset Controller operation on Sysmac Studio the shutdown function is automatically executed before resetting the Controller f Instruction Execution Execute a DB_Shutdown Shutdown DB Connection Service instruction 5 2 4 How to Check the Shutdown of the DB Connection Service Confirm that the DB Connection Service has been shut down by the following methods before turning OFF the power supply to the CPU Unit e Checking with a system defined variable Confirm that _DBC_
163. e guaranteed The Operation Log files may be corrupted or the data may be lost ES Additional Information We recommended that you take countermeasures against power interruption such as installation of uninterruptible power supply system to prevent data loss by unexpected power interruption NJ series Database Connection CPU Units User s Manual W527 5 Other Functions 5 2 2 Shutdown System a The following figure shows the shutdown system ro Sysmac Studio z A iw a Shutdown operation from Sysmac Studio jes O fe CPU Unit Server D O Program c Connections are f a DB Connection a DB Connection Service N loseg Relational Database 9 Instruction DB_Shutdown op Shutdown a rnnnnnnnnnnnnnnnnn Z Service is shut down EtherNevIP port 5 D Yn a A DB_Shutdown Shutdown Operation Log y DB Connection Service S instruction is executed Q NS A O EM Area 5 non volatile memory a Spool Memory L d Operation Log files are 2 stored in the SD Memory INSERT Card O INSERT 5 INSERT SD Memory Card Log File a The DB Connection Service is shut down by a Sysmac Studio operation or by executing a Q DB_Shutdown Shutdown DB Connection Service instruction R b The DB Connection Service is shut
164. e 4 10 System defined Variables ccccceccccesceesseesteeeteeceeeeeee 3 19 T AE ol E E E E E E A 29 Test Modersohn et aeai sees eaetetest 2 5 4 2 Timeout Monitoring Functions 0 0 eee eee eeeeeeees 5 19 Too Many DB Connections ecccecceeeeeeeeeseeeeeeenseens 7 27 Troubleshooting cceeescecessseeeseeeceesececeeseceeceeceeseneeceses 7 7 U Unregistered DB Map Variable cecscceeseeeeeeeees 7 30 UPDATE operation icc aici isin ccd ie ae ii 1 4 V Variables Used in the DB Connection Instructions 3 xoepu Index l 4 NJ series Database Connection CPU Units User s Manual W527 Authorized Distributor
165. e Connection Settings Y DB Connection Connection name DBConnection01 Database type SQL Server v Server specification method IP address Host name IP address Host name Jaooo Riba esr E DEA Instance name Port No eS Can be omitted Service name Database name SR Can be omitted e omon Password for confirmation Sen ea Login timeout Query execution timeout RET comer SIE TD Y DB Communications Test Communications Test Reset all to default Set the following items Category Item Description Value DB Connection Connection name The DB Connection name is You can change the DB Connection name displayed To change the name right click the DB Connection in the Multiview Explorer and select Rename from the menu Database type Set the database type Oracle SQL Server Default Server Select the specification method of IP address Default specification the server Select IP address or Host Host name method name IP address Set the IP address of the server Default Blank This setting cannot be omitted when P address is selected for Server specification method Host name Set the host name of the server Default Blank This setting cannot be omitted when Host name is selected for Server specification method 9 8 NJ series Database Connection CPU Units User s Manual W527 2 DB Connection Settings Category Item Description Value Instance name Por
166. e Connection CPU Units User s Manual W527 Appendix B B 1 2 How to Measure Execution Time of DB Connection Instructions The execution time of DB Connection Instructions can be measured by a Get1msCnt instruction The instruction calculates the value of free running counter of the cycle from when the Busy output variable changes to TRUE to when the variable changes to FALSE lt Example for measuring execution time of a DB_Insert instruction Insert a record to the DB Connection MyDB17 DB_Insert_instance Operating DB Insert Execute Done MyDB1 DBConnection Busy MapVar_Insert MapVar Error TimeOut ErrorID SendStatus Measure execution time of the DB_Insert instruction and output the result to the ExecTime_msec output variable of the SUB instruction DB_Insert_instance Busy GetimsCnt t EN ENO DB_Insert_instance Busy GetimsCnt 4 EN ENO Np dOld ubiseq ysel g EndCnt ExecTime_msec BeginCnt SUOI ONISU UOI 9UUOD gq JO awi uolnoexy NSLE N 0 MOH Z 4 g NJ series Database Connection CPU Units User s Manual W527 B 3 Appendix B B 1 3 Guideline for System Service Execution Time Ratio The DB Connection Service is executed as a system service When a DB Connection Instruction is executed by a user program the DB Connection Service executes the processing as a system service If sufficient execution time cannot be allocated to the system services th
167. e DB Connection Instruction may take long execution time To execute the DB Connection Instructions according to the performance specifications design the task so that the system service execution time ratio CPU usage is 20 or greater Precautions for Safe Use The 20 or greater system service execution time ratio CPU usage is just a guideline The appropriate value of system service execution time ratio CPU usage depends on the usage of other services executed as a system service Before starting actual operation you must test performance under all foreseeable conditions on the actual system and make sure that the DB Connection Instructions are executed within the appropriate execution time B 1 4 Checking the System Service Execution Time Ratio B 4 When you design the tasks confirm that sufficient execution time can be allocated to system services by the following methods Desktop Calculations This is an example for a project that consists of one primary periodic task Refer to the NU series CPU Unit Software User s Manual Cat No W501 to make a rough estimate of the average task execution time on paper Design the task using the following as a guideline Average task execution time lt task period x 0 8 Estimating with the Simulator on Sysmac Studio Check the value of Estimated CPU usage rate with the Task Execution Time Monitor of the Simulator on Sysmac Studio Refer to the NU series CPU Unit Soft
168. e DB Connection specified Connection DB Connection in the DBConnection input is not correct or variable of the relevant the DB instruction is wrong s Connection is The DB Connection specified already closed in the DBConnection input variable of the relevant instruction is closed 5401 3009hex Invalid DB The specified A structure variable that Map Variable DB Map Variable contains a derivative data is not correct type of member was specified as a DB Map Variable Anon structure variable was s specified as a DB Map Variable A structure array variable was specified as a DB Map Variable for INSERT or UPDATE 5401 300Ahex Unregistered The specified The DB Map Variable has DB Map DB Map Variable not been created by a Variable has not been DB_CreateMapping registered instruction A variable that is not registered as a DB Map Variable was specified in S MapVar The DB Connection specified in the relevant instruction is different from the one specified at the execution of DB_CreateMapping instruction NJ series Database Connection CPU Units User s Manual W527 7 11 BHunoousajqnol Z Z gqel 1011F Z Z 7 Troubleshooting Event code Event name Meaning Assumed cause Level Maj Prt Min Obs Info Reference 5401 300B hex SQL Execution Error The executed SQL statement resulted in an error There is no column with the same name as a Structure member of t
169. e data type by a DB_CreateMapping instruction TimeOut Timeout TIME T 0s T 0s Specify the time to detect timeout T 0 05s to When T 0s is specified timeout is not T 180s monitored f Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or oes TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or nae TRUE when the instruction is being executed FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to FALSE an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF SendStatus Send _eDBC_SEND_STATUS Depends on Outputs the progress of transmission of the SQL Status the data type statement A 14 NJ series Database Connection CPU Units User s Manual W527 Appendix A Related System defined Variables _EIP_EtnOnlineSta Data type Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used Related Error Codes Error code Meaning Description 0400 hex Input Value Out of Range The value of the TimeOut input variable is outside the valid range 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same time Same Time 3000 hex DB Connection Service not Started The ins
170. e or Test Mode Operation Mode When each instruction is executed the service actually accesses the DB Test Mode When each instruction is executed the service ends the instruction normally without accessing the DB actually Spool function Used to store SQL statements when an error occurred and resend the statements when the communications are recovered from the error Spool capacity 1 MB NJ series Database Connection CPU Units User s Manual W527 1 Introduction to the DB Connection Service Item Description Operation Log function The following three types of logs can be recorded lt Execution Log Log for tracing the executions of the DB Connection Service Debug Log Detailed log for SQL statement executions of the DB Connection Service SQL Execution Failure Log Log for execution failures of SQL statements in the DB DB Connection Service shutdown function Used to shut down the DB Connection Service after automatically saving the Operation Log files into the SD Memory Card 1 The CIP Common Industrial Protocol communications using the built in EtherNet IP port support the same functions as with the following CPU models Therefore when executing the EtherNet IP tag data link function please specify the following CPU models on Network Configurator The following models are also displayed in Sysmac Gateway or CX Compolet NJ501 1500 for NJ501 1520 NJ501 1400 for NJ501 1420 NJ501 1300 for N
171. e same Same Time time 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was Shutting Down shut down or while the DB Connection Service was being shut down 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress Function This instruction is used to get the current status of the DB Connection Service The current status is output to the ServiceStatus output variable Refer to the m ServiceStatus of A 1 2 Variables Used in the DB Connection Instructions for the status Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing e Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur An error occurs for this instruction in the following cases Error will be TRUE When the instruction was executed while the initialization processing of t
172. e spooling order by one execution of the DB_ControlSpool Resend Clear Spool Data instruction CPU Unit Server Program a DB Connection Service oN DB Connection Instruction i Re sannactad Relational Database DB_ControlSpool m INSERTA l EtherNet IP l 2 SQL statements stored in the Spool memory are resent in the spooling order EM Area 1 When communications non volatile memory are recovered i e f Spool Memory gt when the DB is reconnected a INSERT DB_ControlSpool INSERT instruction is executed INSERT to resend the SQL F statements stored in the Spool memory NS D 5 6 NJ series Database Connection CPU Units User s Manual W527 5 Other Functions If a Failure Occurred in Information Exchange with the DB when Resending the SQL Statements If a failure occurred again when the SQL statements stored in the Spool memory are resent the unsent SQL statements are kept in the Spool memory The SQL statements are resent again by auto resend or manual resend The resend order is not changed 5 1 7 Clearing the SQL Statements from the Spool Memory The SQL statements are cleared from the Spool memory in the following cases When the specified clear condition is met e When a DB_ControlSpool Resend Clear Spool Data instruction is executed When the Clear Spool Dat
173. e the DB Connection Service is running Operation Log SD Memory Card Replacing Status If Execution Log is contained in the internal buffer of the CPU Unit it is recorded into the SD Memory Card recorded into the internal buffer of the CPU Unit function When the SD Memory Card When no SD When an SD Memory Card is power supply switch is pressed Memory Card is inserted mounted Execution Log Continued Temporarily The log that is temporarily recorded in the internal buffer is automatically recorded to the SD Memory Card Debug Log Stopped If Debug Log is contained in the internal buffer of the CPU Unit it is recorded into the SD Memory Card Debug Log is not recorded Recording to the Debug Log is still stopped Recording is started by an online operation from Sysmac Studio or by executing a DB_ControlService Control DB Connection Service instruction SQL Execution Failure Log Stopped If SQL Execution Failure Log is contained in the internal buffer of the CPU Unit it is recorded into the SD Memory Card SQL Execution Failure Log is not recorded Recording to the SQL Execution Failure Log is automatically started l Precautions for Correct Use Please note the following for replacing the SD Memory Card Use a formatted SD Memory Card when replacing the SD Memory Card e When you replace the SD Memory Card while recording the Execution Log press the SD
174. e time long in the Debug Log and change the in the Debug Log and specify an timeout parameter to an appropriate value in the timeout appropriate value parameter Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks Event name DB Connection Service Error Stop Event code 5401 3013 hex Meaning The instruction could not be executed because the DB Connection Service was stopped due to an error Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None ae Cause and Assumed cause Correction Prevention correction The DB Connection settings are Transfer the DB Connection Do not interrupt the power supply corrupted settings again using the to the Controller during a download synchronization function of of the DB Connection
175. eMapping_Insert_instance Error DB_CreateMapping_Update_instance Error Accept the trigger for establishing the DB Connection RS_Connect_instance Operating _Connect Trigger_Connect _DBC_Status Run AS t Set Q1 OperatingEnd_Connect Reset Establish the DB Connection named MyDatabase1 DB_Connect_instance Operating_Connect DB Connect Execute Done MyDatabase1 DBConnectionName Busy Error ErrorlD DBConnection Map the variable MapVar_Insert to the table Production of the DB Connection MyDB1 for the INSERT operation DB_CreateMapping_Insert_instance DB_Connect_instance Done DB_CreateMapping Execute Done MyDB1 pBConnection Busy Production TableName Error MapVar_Insert MapVar ErrorlD _DBC_SQLTYPE_INSERT SQLType A 24 NJ series Database Connection CPU Units User s Manual W527 Appendix A Map the variable MapVar_Update to the table Production of the DB Connection MyDB1 for the UPDATE operation DB_CreateMapping_Update_instance DB_CreateMapping_Insert_instance Done DB_CreateMapping Execute Done MyDB1 DBConnection Busy Production TableName Error MapVar_Update MapVar ErrorlD _DBC_SQLTYPE_UPDATE 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
176. e_instance Execute FALSE OperatingStart_Close FALSE END_IF Close the DB Connection MyDB1 IF Operating _Close TRUE THEN A 52 NJ series Database Connection CPU Units User s Manual W527 Close the DB Connection DB_Close_instance Execute TRUE DBConnection MyDB1 IF DB_Close_instance Done TRUE THEN Operating_Close FALSE Normal end END_IF IF DB_Close_instance Error TRUE THEN Error handler Program the error handler FaultHandler_Close according to the device FaultHandler_Close Operating_Close FALSE ENDIF ENDIF NJ series Database Connection CPU Units User s Manual W527 Appendix A A 53 J uW QO O 3 5 oO QO O 5 gt A 2 c QO O 3 na 91919q ga p10094 gq 1912 Appendix A DB_ControlService Control DB Connection Service The DB_ControlService instruction starts stops the DB Connection Service or starts finishes recording to the Debug Log Instruction DB_ControlService Name Connection Service FB FUN Control DB FB Graphic expression DB_ConirolService_instance DB_ConirolService Execute Done Cmd Busy Error ErrorlD ST expression DB_ControlService_instance Execute Cmd Done Busy Error ErrorlD Note The DB_ControlService_instance is an instance of DB_ControlService instruction which is declared as a variable Variables i Input Variables Name Meaning Data ty
177. e_instance is an instance of DB_Update instruction which is declared as a variable Variables i Input Variables Name Meaning Data type Valid range Unit Default Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition DBConnection DB Connection DWORD 16 00000000 to 16 0000 Specify the DB Connection established 16 FFFFFFFF 0000 by a DB_Connect instruction MapVar DB Map Structure Depends on the Specify the DB Map Variable mapped Variable data type by a DB_CreateMapping instruction Where Retrieval STRING 1 986 bytes max Specify a text string that expresses Conditions including the final retrieval conditions WHERE clause NULL character WHERE is not included TimeOut Timeout TIME T 0s T 0s Specify the time to detect timeout T 0 05s to When T 0s is specified timeout is not T 180s monitored A 18 NJ series Database Connection CPU Units User s Manual W527 Appendix A i Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or s TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or TRUE when the instruction is being executed FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to FALSE an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF RecCnt Number of DINT 0 to Contains the number of r
178. eaeees 3 13 3 5 Programming and Transfer eeceeceeeeseeeeeeeeeeeeeeeeeeeeeeseeeeeeeeseaeesersaeeeeeeaas 3 16 3 5 1 Programming the DB Connection ServiCe cccceeceeeeseeeeeees 3 16 3 5 2 Displaying DB Connection Instructions on Sysmac Studio 3 17 3 5 3 DB Connection Instruction Set ccccccecseeeeeseseeeeeseceeeeneeeeenees 3 18 3 5 4 System defined Variables cccccccceceeeeeeeeeeeeseeeseeeeeseaeeseneeeeaes 3 19 3 5 5 Simulation Debugging of DB Connection Instructions 3 19 3 5 6 Transferring the DB Connection Settings and User Program 3 19 3 6 Debugging in Design Startup and Operation Phases cseeeeees 3 20 3 6 1 Design Phase 2itiscc ceases pana E T Aa tents datesithtee kt teed tees 3 20 3 6 2 Start p Phase a leis cats Sbieesah oes a hes teeta Geezer eg esi teed 3 20 3 6 3 Operation Phase visi tthaiee iene ei tee eee 3 21 NJ series Database Connection CPU Units User s Manual W527 3 1 3 Programming the DB Connection Function 3 1 DB Access Procedure 3 2 This section describes a specific programming procedure for using the DB Connection Service Refer to the NJ series CPU Unit Software User s Manual Cat No W501 for the general programming procedure Use the following procedure to access the DB using DB Connection Instructions after making the DB Connection settings After the DB mapping you can read from and write to the DB using
179. ecord in Saved when transmission of an SQL statement Failure Log the DB Connection Service Settings of failed due to a DB caused factor Sysmac Studio 1 If the power supply to the CPU Unit is turned ON while no SD Memory Card is mounted in the CPU Unit an Execution Log Save Failed Error is registered into the event log when the Execution Log is saved Recording to the Execution Log is started when an SD Memory Card is inserted into the CPU Unit 2 If the power supply to the CPU Unit is turned ON while no SD Memory Card is mounted in the CPU Unit an SQL Execution Failure Log Save Failed Error is registered into the event log when the SQL Execution Failure Log is saved Recording to the SQL Execution Failure Log is started when an SD Memory Card is inserted into the CPU Unit Directory Used for DB Connection Service The DB Connection Service uses the directory under packages DB_Connection in the SD Memory Card packages DB_Connection System Contains log control files packages DB_Connection ExecutionLog Contains Execution Log files packages DB_Connection DebugLog Contains Debug Log files packages DB_Connection SQLFailedLog Contains SQL Execution Failure Log files NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 5 3 Operation Log Operations in Replacing the SD Memory Card This section describes operations of each Operation Log when the SD Memory Card is replaced whil
180. ecords that were Records 2147483647 updated SendStatus Send _eDBC_SEND_STATUS Depends on Outputs the progress of transmission of the SQL Status the data type statement Related System defined Variables Online Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used _EIP_EtnOnlineSta Related Error Codes J W QO O 3 5 oO QO O 5 gt na pce c Q O 5 na Error code Meaning Description 0400 hex Input Value Out of Range The value of the Timeout input variable is outside the valid range 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same time Same Time 3000 hex DB Connection Service not Started The instruction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was shut Shutting Down down or while the DB Connection Service was being shut down Ww 3008 hex Invalid DB Connection The value of the DBConnection input variable is invalid or the specified DB i Connection is already closed 300A hex DB Map Variable Unregistered The variable specified in the MapVar input variable has not been mapped n by a DB_CreateMapping instruction Ee 300B hex SQL Execution Error The executed SQL statement resulted in a
181. ect error DB_Select instruction The user does not have the Check the access rights to the Confirm the access rights to the access rights to the table table table Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 31 N BHunooyseqnol Z Z suonduos q 10113 2 2 2 7 Troubleshooting Event name Spool Capacity Exceeded Event code 5401 300C hex Meaning The SQL statement could not be stored in the Spool memory because its maximum capacity was exceeded Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction The DB connect
182. ecuted by special instructions Recording of Operation Logs 1 2 You can save the execution result logs of special instructions and processing i e internal SQL statements as a log file into the SD Memory Card mounted in the CPU Unit Also you can check the logs using Sysmac Studio or FTP client software NJ series Database Connection CPU Units User s Manual W527 1 Introduction to the DB Connection Service Fail safe Design against Errors and Power Interruption You can spool the data i e internal SQL statements if the data cannot be sent due to an information exchange error with the DB and execute the processing when the communications are recovered from the failure e You can automatically save the Operation Logs by shutting down the DB Connection Service when turning OFF the power supply to the CPU Unit j Making a Library of DB Access Function You can provide and reuse the special instructions as a library file by describing each special instruction as a user defined function block s 1N e 4 PUL MAIAJOAC L 4 1 _ 1 N TI D a5 Cc x D n NJ series Database Connection CPU Units User s Manual W527 1 3 1 Introduction to the DB Connection Service 1 2 DB Connection Service Specifications and System This section describes the specifications and system of the DB Connection Service 1 2 1 DB Connection Service Specifications The following table shows the specifications of the DB
183. ed use and one copy of the programs for backup purposes You may not use the programs for any purpose other than as provided above distribute the programs unless accompanied with your applications charge your end users for use of the programs remove or modify any program markings or any notice of our proprietary rights use the programs to provide third party training on the content and or functionality of the programs except for training your licensed users assign this agreement or give the programs program access or an interest in the programs to any individual or entity except as provided under this agreement Cause or permit reverse engineering unless required by law for interoperability disassembly or decompilation of the programs disclose results of any program benchmark tests without our prior consent Program Distribution We grant you a nonexclusive nontransferable right to copy and distribute the programs to your end users provided that you do not charge your end users for use of the programs and provided your end users may only use the programs to run your applications for their business operations Prior to distributing the programs you shall require your end users to execute an agreement binding them to terms consistent with those contained in this section and the sections of this agreement entitled License Rights Ownership and Restrictions Export Disclaimer of Warranties and Exclusive Remed
184. ed when this variable is TRUE OperatingStart_Select BOOL FALSE The start processing for retrieving DB records is executed when this variable is TRUE WhereCond_Select STRING 256 This variable is assigned to the Where input variable to DB_Select_instance SortCond_Select STRING 256 This variable is assigned to the Sort input variable to DB_Select_instance DB_Delete_instance DB_Delete Instance of DB_Delete instruction WhereCond_Delete STRING 256 This variable is assigned to the Where input variable to DB_Delete_instance Request_Delete BOOL FALSE The DB_Delete instruction is executed when this variable is TRUE LastRequest_Delete BOOL FALSE Variable to retain the request status of the previous execution Operating_Delete BOOL FALSE The DB_Delete instruction is executed when this variable is TRUE OperatingStart_Delete BOOL FALSE The start processing for deleting DB records is executed when this variable is TRUE DB_Close_instance DB_Close Instance of DB_Close instruction Trigger_Close BOOL FALSE Variable used as a trigger for closing the DB Connection LastTrigger_Close BOOL FALSE Variable to retain the trigger status of the previous execution Operating_Close BOOL FALSE The DB_Close instruction is executed when this variable is TRUE OperatingStart_Close BOOL FALSE The start processing for closing the DB Connection is executed when this variable is TRUE Stage INT acs Variable that shows the status of the DB
185. ee tt hn St Nite eg ul le a B 1 B 1 Task Design Proceduren ianen enade eriadan aa iant B 2 B 1 1 Reference Values for Execution Time of DB Connection Maire ono IAA E EAE A A EAA A A eee hate EAE AA B 2 B 1 2 How to Measure Execution Time of DB Connection Instructions B 3 B 1 3 Guideline for System Service Execution Time Ratio c ce B 4 B 1 4 Checking the System Service Execution Time Ratio 000 B 4 B 2 Execution Time of DB Connection INStructionS cccccccccccseceeeeeeececeeeeeeeeeeeeesseeeeeeess B 6 B 2 1 Restrictions to Execution Time of DB Connection Instructions B 6 B 2 2 Impact of Operation Log Recording on Execution Time of DB Connection Instructions cece ccc cccc cess eececceeesseaeeueeeeeeeeeaueaeeeeeeas B 8 B 2 3 How to Measure DB Response Time ccccceeeeeeeeeeeeeeteeeeseeeeaes B 9 B 2 4 Ensuring Equipment Performance Takt Time by Monitoring Instruction Execution Timeout ccccecssssesecececssscecetecsessseresees B 10 Index 10 NJ series Database Connection CPU Units User s Manual W527 Terms and Conditions Agreement Terms and Conditions Agreement Read and understand this Manual Please read and understand this catalog before purchasing the products Please consult your OMRON representative if you have any questions or comments Warranty Limitations of Liability Warranties Exclusive Warranty Omron s exclusive warranty is that the Pr
186. eeceeeaeeeeneeees 4 13 Restrictions on DB Map Variables cceeeseeeeeeees 3 11 Restrictions on DB Mapping u ccceeccccceeceeseseeeeeeeeeeens 3 13 restrictions on structure member names in the NJ series Controllers tsi sancti i i Restrictions on Table s Column Names Run Mode of the DB Connection Service SELECT operation c cccccccccsccseseceseceseceesceesseesseeeneeensees 1 4 Service Start Specifications of Structure Data Type for DB Access 3 3 Spool Capacity Exceeded cccccceccceeceeseesteesteeeeeeeeee Spool datas cic aeyn eraa i aai Spool f nctionesr iseni re ioi Spool Function ccccceceseceseecseeceeeceseceeceseeeeeseeeneecnseensees Spool Function Settings 0 ccccccesccsecceceesseeseeeenseeesees Spool Memory Corrupted 2 Spool Settings eree y iene eden ee Spool tisage i cv ceci TE SQL sciesiecsitncarlhian asada acldavniiand SQL Execution Error ne SQL Execution Failure Log A 29 2 6 SQL Execution Failure Log Save Failed 7 18 SQL Server aaae e e e r a e 1 2 1 4 SQL Status ceni hani Acticin E 4 13 SOLTE eni eiaa r a T ee 3 9 3 12 Structure data type for DB access c ccsceeeseeseeeteees A 29 Structure member name 0 ccccecccesecesseeseseesteecseecsseeesees 3 3 Structure member s data type sssssessssesesssseresrsseresrssees 3 3 Struct urenamMment srein re res a r aE E 33 System defined Variable 0 ccecceccceeeeeeeeteeeteeeeeeeee
187. elect w EN FaultHander_Select Bo D Q Q If two or more records were retrieved delete the records other than the latest one 2 Operating_Select DB_Select_instance Done D E Normal end processing IF DB_Select_instance SelectedCnt gt 1 THEN Request_Delete TRUE END_IF NJ series Database Connection CPU Units User s Manual W527 A 45 Appendix A Delete the records other than the latest one from the DB table Check the completion of the DB_Delete instruction DB_Delete_instance Done OperatingEnd_Delete DB_Delete_instance Error Accept the trigger for deleting DB records RS_Delete_instance Request_Delete Operating_Delete OperatingEnd_Delete Create the conditions for the Where clause Operating_Delete Create the conditions for the Where clause Delete the records other than the latest one WhereCond_Delete CONCAT LotNo t UINT_TO_STRING LotNo AND FinishTime lt TO_TIMESTAMP DtToString MapVar_Select 0 FinishTime YYYY MM DD HH24 MI SS FF9 Delete records from the table Production of the DB Connection MyDB1 Timeout is not monitored for the instruction execution DB_Delete_instance Operating_Delete DB Delete Execute Done MyDB1 DBConnection Busy Production TableName Error WhereCond_Delete Where ErrorID TimeOut RecCnt Execute the normal end processing Operatin
188. en an SQL statement execution failed executions This is the number of times when an SQL statement is not spooled but discarded The number of times when a statement is spooled is not included This value is cleared when the DB Connection Service is started Number of Spool Number of SQL statements stored in the Spool memory data This value returns to 0 when the Spool data is cleared Spool usage Use rate of the Spool memory for the DB Connection in percentage This value returns to 0 when the Spool data is cleared Disconnection Date and time when the DB is disconnected due to a network failure server s date time problem or other causes This value is cleared when the DB Connection Service is started SQL status Error code defined in SQL Standards ISO IEC 9075 to be shown when a network failure or an SQL Execution Error occurred This value is cleared when the DB Connection Service is started Error code Error code that is specific to DB vendor to be shown when a network failure or an SQL Execution Error occurred When a network error has occurred 0 is displayed for error code in some cases When 0 is displayed check its SQL status This value is cleared when the DB Connection Service is started Error message Error message that is specific to DB vendor to be shown when a network failure or an SQL Execution Error occurred This value is cleared when the DB Connection Service is started 4 14 NJ seri
189. endix A DB_PutLog Record Operation Log The DB_PutLog instruction puts a user specified record into the Execution Log or Debug Log Instruction DB_PutLog Record Operation Log Name FB FUN FB Execute LogType LogCode LogName Graphic expression DB_PutLog_instance DB_PutLog Done Busy Error ErrorlD LogMsg ST expression DB_PutLog_instance Execute LogType LogCode LogName LogMsg Done Busy Error ErrorlD Note The DB_PutLog_instance is an instance of DB_PutLog instruction which is declared as a variable Variables Input Variables Name Meaning Data type Valid range Default Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition LogType Log Type _eDBC_LOGTYPE _DBC_LOGTYPE_EXECUTION 1 0 Specify the type of Execution Log log to output _DBC_LOGTYPE_DEBUG 2 Debug Log LogCode Log Code INT 0 to 9999 0 Specify the code to record in the log LogName Log Name STRING 33 bytes max including the final k Specify the name to NULL character record in the log LogMsg Log Message STRING 129 bytes max including the final u Specify the message NULL character to record in the log i Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or TRUE when the instruction is being e
190. ent after a DB_Update Update DB Record instruction is executed e When an SQL statement is stored in the Spool memory 0003 SELECT Before the DB Connection Service sends an SQL statement after a DB_Select Retrieve DB Record instruction is executed 0004 DELETE Before the DB Connection Service sends an SQL statement after a DB_Delete Delete DB Record instruction is executed SQL Execution 0001 INSERT When a response succeeded failed is Result returned to the INSERT issued from DB Connection Service to DB 0002 UPDATE When a response succeeded failed is returned to the UPDATE issued from DB Connection Service to DB 0003 SELECT When a response succeeded failed is returned to the SELECT issued from DB Connection Service to DB 0004 DELETE When a response succeeded failed is returned to the DELETE issued from DB Connection Service to DB User specified 0000 to 9999 DB_PutLog Instruction When aDB_PutLog Record Operation Log Log specified by Executed instruction is executed the user 4 Log Name Category Operation Log name DB Connection DB Connection Established Connect SQL INSERT INSERT UPDATE UPDATE SELECT SELECT DELETE DELETE SQL Execution INSERT INSERT Result UPDATE UPDATE SELECT SELECT DELETE DELETE User specified Log DB_PutLog Instruction Executed Text string specified in the LogName input variable of the DB_PutLog instruction 6 16 NJ series Database Connection CPU Units User s Manual W527 6 How
191. ent them from developing into errors at the minor fault level or higher Information errors Events that are classified as information provide information that do not indicate i DB Connection Service Errors by Source The following tables list the errors in each event level that can occur for each source NJ series Database Connection CPU Units User s Manual W527 7 5 SION JO M IM AQ L Z BOIAIOS UO INBUUOD Gq SU 0 payejoy S104117 Z Z 7 Troubleshooting DB Connection Service Errors Level Error name Major fault None Partial fault None Minor fault Spool Memory Corrupted Execution Log Save Failed SQL Execution Failure Log Save Failed DB Connection Setting Error DB Connection Disconnected Error Observation None Information DB Connection Service Started DB Connection Service Stopped DB Connection Service Shutdown DB Connection Instruction Errors Level Error name Major fault None Partial fault None Minor fault None Observation DB Connection Service Not Started DB Connection Service Run Mode Change Failed DB Connection Service Shutdown or Shutting Down Invalid DB Connection Name DB Connection Rejected DB Connection Failed DB Connection Already Established Too Many DB Connections Invalid DB Connection Invalid DB Map Variable Unregistered DB Map Variable SQL Execution Error Spool Capacity Excee
192. erations of the DB Connection function on the CPU Unit There are three types of Operation Logs Execution Log Debug Log and SQL Execution Failure Log Run mode of the DB Connection Service Used to switch whether to actually access the DB or to normally end the instructions without accessing the DB when DB Connection Instructions are executed Spool memory Spool function Refers to the memory area for storing the SQL statements in the Spool function Used to store some SQL statements for inserting records into the DB or updating the records in the DB that could not be executed due to a network failure Spool data Refers to the SQL statements stored in the Spool memory Structure data type for DB access Refers to structure data type where all or some of the columns of a specified table are registered as structure members SQL Stands for Structured Query Language which is one of the languages for DB processing such as data read write SQL Execution Failure Log One of the Operation Logs This log is used to record execution failure of SQL statements in the DB SQL statement Refers to the statements that show a specific instruction used for DB operations such as data read write Table One of the information layers of each DB which contains data NJ series Database Connection CPU Units User s Manual W527 29 Revision History Revision History A manual revision code appears as
193. es Database Connection CPU Units User s Manual W527 Other Functions Sz This section describes other functions of the DB Connection Service 5 1 SPOOL FUMCUOMN renan n e eean a a aa ada e fees sere vdeo teen 5 2 5 1 1 OVE W naea a E AAEN 5 2 5 1 2 SPOONING SYSUSM ee raataa aenean eect aaa Maak aaa aia a Kandia 5 2 5 1 3 Applicable Instructions and Spooling Execution Conditions 5 2 5 1 4 Memory Area Used by the Spool Function 5 4 5 1 5 Spool Function SettingS eeeceeeceeneeceeeeeeeaeeeeeeseeeeeessaeeseaeeeeeees 5 5 5 1 6 How to Resend the SQL Statements Stored in the Spool Memory 5 6 5 1 7 Clearing the SQL Statements from the Spool Memory 06 5 7 5 1 8 Relationship with the DB Connection Instructions 0ccee 5 9 5 1 9 How to Estimate the Number of SQL Statements that Can be Spooled 5 11 5 2 DB Connection Service Shutdown Function cceseeeceeeeeeeteeeeesnneeeeeenes 5 12 5 2 1 OV EIVICW er E ce tvevtiea titans anette A S 5 12 5 2 2 Shutdown Syste ga ani ee aai etaa aate aaka ia aitaita Gea taaa 5 13 5 2 3 How to Execute the Shutdown Function s 5 13 5 2 4 How to Check the Shutdown of the DB Connection Service 5 14 5 3 How to Prevent Losing SQL Statements at Power Interruption 5 15 5 3 1 OVESEN Trena e E E SE EA 5 15 5 3 2 Pro edUrES zisaidie aaa eile 5 15 5 4 Timeout Monitoring FunctionS eeessseesseesesiresseietsrrirsrerrtretiirnes
194. es Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur When this instruction is executed during replacement of the SD Memory Card the following operations are performed NJ series Database Connection CPU Units User s Manual W527 A 79 J W QO O 3 5 oO QO O 5 gt A 2 c QO O 3 na eyeq joods sea D puesey joodsjouu0D gq Appendix A When the Execution Log is specified The log is recorded to the internal buffer of the CPU Unit and the instruction is completed normally When an SD Memory Card is inserted into the CPU Unit the log records stored in the internal buffer are saved into the SD Memory Card When the Debug Log is specified The Debug Log cannot be recorded The instruction is terminated due to an error Operation Log Disabled An error occurs for this instruction in the following cases Error will be TRUE e When the instruction was executed while the initialization processing of the DB Connection Service was in progress e When the instruction was executed while the DB Connection Service was stopped due to an error e When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down e When a value that is not defined as an enumerator was specified in the LogType input variable e When the
195. es and data types and enter the name of the structure data type 5 Enter STRUCT in the Data Type column on the inserted line 6 Copy the data area under the Column Name and Data Type as shown below A B p lt Table name 1 2 3 4 lt Column 1 5 6 Sear 20 lt Column 2 WYCOLUMN3 o STRINGI20 lt Column 3 A structure data type is created as shown below Be Programming ee Base Type Offset Typel Offset Bytel q eRe l Union Enumerated 3 8 NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function 3 3 Creating a DB Map Variable 3 3 1 After creating a user defined structure data type for DB access you create a variable using the data type The variable is called DB Map Variable This section describes the specifications and creation procedure of DB Map Variables DB Map Variables and DB Mapping Each DB Map Variable uses a structure data type for DB access as its data type You create a mapping for a DB Map Variable to the connected DB for each SQL type i e INSERT UPDATE and SELECT by executing a DB CreateMapping Create DB Map instruction After creating the DB mapping you can execute each record processing for inserting updating and retrieving records using the DB Map Variable by executing a DB_Insert Insert DB Record DB_Update Update DB Record or DB_Select Retrieve DB Record instruction
196. eseceeeeeeeaes 7 36 Database ty pe iii ssccccessctscascneassssesustesssapsencssdscedsstusdtucceucesed 2 8 TOBA cbccitteste Mest tcsicet Sate Mack we citeh tho Me A wor de ko teal gel A 29 DB Connection ececcceecccesseesseeeeeeeeeeceeceeecesaeesneeeeeeeee A 29 DB Connection Already Established cceeeeeeee 7 27 DB Connection Disconnected Error c cccccecceeseeerees 7 20 DB Connection Disconnected Error Status 006 7 34 DB Connection Failed cccceecccesseecseecesecesecenecenseensaes 7 26 DB Connection function cccccccesceee cess ceeeteesteeeeeeeeee A 29 DB Connection Instruction cccccceceseeeseeeseeeeeeeeeee A 29 DB Connection Instruction Execution Timeout 7 35 DB Connection Instruction Set cceeeeseeseeeeeesees 3 18 DB Connection Rejected sesesssesesesseeersseesrseressserese 7 26 DB Connection Service cccccccssseecessccesessecessteeeees A 29 1 4 DB Connection Service Error Stop ccccccesccesseesseeeees 7 35 DB Connection Service Initializing 0 0 0 ee eeeeereeeee 7 36 DB Connection Service Not Started cccceceeeseeeees 7 23 DB Connection Service Run Mode Change Failed 7 24 DB Connection Service Settings ccccecceecseereeteeeeeeee 2 4 DB Connection Service Shutdown cccceccceeseeeseeeees 7 22 DB Connection Service shutdown function A 29 1 5 5 12 DB Connection Service Shutdown or Shutting Down 7 25 DB Conne
197. evel Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None ato Cause and Assumed cause Correction Prevention correction A server does not exist for the Enter the correct IP address or Enter the correct IP address or host specified IP address or the host name in the DB Connection name in the DB Connection specified host name settings settings The power supply to the server is Check the server status and start it Check the server status and start it OFF properly properly The DB is stopped in the server The Ethernet cable connector is Reconnect the connector and Connect the connector securely disconnected make sure it is mated correctly The Ethernet cable is broken Replace the Ethernet cable None Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks 7 26 NJ series Database Connection CPU Units User s Manu
198. f you comply with the terms below o You may copy and distribute the object code form of the software Distributable Code in programs you develop You may not modify the software o You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs ii Distribution Requirements For any Distributable Code you distribute you must o add significant primary functionality to it in your programs o require distributors and external end users to agree to terms that protect it at least as much as this agreement o display your valid copyright notice on your programs and o indemnify defend and hold harmless Microsoft from any claims including attorneys fees related to the distribution or use of your programs iii Distribution Restrictions You may not o alter any copyright trademark or patent notice in the Distributable Code o use Microsoft s trademarks in your programs names or in a way that suggests your programs come from or are endorsed by Microsoft o include Distributable Code in malicious deceptive or unlawful programs or o modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License An Excluded License is one that requires as a condition of use modification or distribution that o the code be disclosed or distributed in source code form or o others have the right to modify it SCOPE OF LICENSE The software is l
199. fined Variables ES onog Name Data type Valid range Description variables _DBC_Status Run DB Connection BOOL TRUE or FALSE This variable changes to FALSE when this Service Running instruction is executed Status _DBC_Status Test DB Connection BOOL TRUE or FALSE This variable changes to FALSE when this Service Test Mode instruction is executed Status _DBC_Status Shutdown DB Connection BOOL TRUE or FALSE This variable changes to TRUE when this Service Shutdown instruction is executed Status A 84 NJ series Database Connection CPU Units User s Manual W527 Appendix A Related Error Codes Error code Meaning Description 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same Same Time time 3001 hex DB Connection Service Run Mode Change The instruction was executed while the stopping processing of the DB Failed Connection Service was in progress 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was Shutting Down shut down or while the DB Connection Service was being shut down 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress Function This instruction is used to shut down the DB Connection Service Be sure to execute this instruction before turning OFF the power supply to the CPU Unit to
200. g 9 4 NJ series Database Connection CPU Units User s Manual W527 2 DB Connection Settings Service Settings Make a setting for Service Start Execution Log Debug Log and SQL Execution Failure Log in the Service Settings Refer to 4 1 Run Mode of DB Connection Service and Start Stop Procedures for details on how to start the DB Connection Service Refer to 6 How to Use Operation Logs for details on the Operation Logs Configurations and Setup DB Connection Service Sex ae v Service Start Service start in RUN mode Auto start Operation Mode v v Execution Log Execution log Record Do not record Number of files 48 Bn Number of records 7200 EES Cyan Y Debug Log Number of files files File size MB When the log is full Stop logging v Delete the log at recording start Delete Do not delete v SQL Execution Failure Log SQL execution failure log Donotrecord Record Number of files SED files File size Me Reset all to default AAAA a Q kX Set the following items Value Category Item Description Service Start Service start in RUN mode Set whether to automatically start the DB Connection Service when the operating mode of the CPU Unit is set to RUN mode Auto start Operation Mode Default Auto start Test Mode Do not start automatically Execution Log Execution log Set whether to record the Execution Log Record Defau
201. g Test Mode A a Idle 2s Error 8 D Refer to 4 3 1 Operation Status cn of the DB Connection Service a Operating time Time elapsed since the DB Connection Service was Duration D a started Unit d h m s a gt Operation Debug log ON while the Debug Log is recorded ON OFF Log 9 Query Number of normal Total number of times in all connections when an Number of normal executions Execution executions SQL statement is normally executed 2 2 Including the number of times when a spooled SQL oo statement is resent 35 This value is cleared when the DB Connection Service is started Number of error Total number of times in all connections when an Number of error executions executions SQL statement execution failed This is the number of times when an SQL statement is not spooled but discarded The number of times when a statement is spooled is not included This value is cleared when the DB Connection Service is started Spooling Number of spool Number of spooled SQL statements in all Number of Spool data data connections The Debug log flag remains ON even if recording to the log is stopped in the following cases When the When the log is full parameter is set to Stop logging in the Service Settings and the maximum number of files is reached When the SD Memory Card capacity is insufficient When writing to the SD Memory Card failed Checking the Status using a Get DB Connection Service Status Instruction Yo
202. g column of the table Refer to Correspondence of Data Types between NJ series Controllers and DB for details However you cannot specify the following data types and attribute for structure members Derivative data types Array attribute NJ series Database Connection CPU Units User s Manual W527 3 3 3 Programming the DB Connection Function H Precautions for Correct Use Restrictions on Table s Column Names You need to specify the same name for structure members to be used in NJ series Controllers as the column names of the table to access There are following restrictions on structure member names in the NJ series Controllers Therefore make the column names satisfy the following conditions Item Description Usable characters 0to9 AtoZ atoz Single byte Japanese kana _ underscores Multi byte characters e g Japanese Characters that cannot be used together A text string that starts with a number 0 to 9 A text string that starts with P_ A text string that starts with an underscore _ character A text string that contains more than one underscore _ character A text string that ends in an underscore _ character Any text string that consists of an identifier and has a prefix or postfix which contains more than one extended empty space character i e multi byte spaces or any other empty Unicode space characters Correspondence of Data Types between Nu
203. g_Delete DB_Delete_instance Done When the instruction is terminated due to an error execute the error handler for the device FaultHandler_Delete Program the FaultHandler_Delete for the device Normal end processing Request_Delete FALSE Operating_Delete DB_Delete_instance Error Error handler FaultHandler_Delete Request_Delete FALSE A 46 NJ series Database Connection CPU Units User s Manual W527 Appendix A Close the DB Connection MyDB1 Check the completion of the DB_Close instruction DB_Close_instance Done OperatingEnd_Close DB_Close_instance Error Accept the trigger for closing the DB Connection RS_Close_instance Operating_Close Trigger_Close h Close the DB Connection MyDB1 OperatingEnd_Close DB_Close_instance Operating_Close DB Close Execute Done DBConnection Busy Error ErrorlD When the instruction is terminated due to an error execute the error handler for the device FaultHandler_Close Program the FaultHandler_Close according to the device J W QO O 5 5 oO QO O 5 gt na 2 c QO O 3 an Operating_Close DB _Close_instance Error E FaultHandler_Close EN FaultHandler_Close O i Structured Text ST J D Main Variables 2 Name Data type Initial value Comment _DBC_Status _sDBC_STATUS System defined variable that shows the
204. ging errors that may be Manual NJ301 the errors that detected in an NJ series Controller and may be detected information on individual errors are described in an NJ series Use this manual together with the NJ series CPU Controller Unit Hardware User s Manual Cat No W500 and NJ series CPU Unit Software User s Manual Cat No W501 Sysmac Studio Version 1 W504 SYSMAC SE2L I Learning about Describes the operating procedures of Sysmac Operation Manual the operating Studio procedures and functions of Sysmac Studio NJ series CPU Unit W506 NJ501 Using the built in Information on the built in EtherNet IP port is Built in EtherNet IP Port NJ301 EtherNet IP port provided Information is provided on the basic User s Manual on an Nu series setup tag data links and other features CPU Unit Use this manual together with the NJ series CPU Unit Hardware User s Manual Cat No W500 and NJ series CPU Unit Software User s Manual Cat No W501 NJ series Database W527 NJ501 11120 Learning about Describes the functions and application Connection CPU Units User s Manual this manual the functions and application procedures of the NJ series DB Connection function procedures of the NJ series DB Connection function 28 NJ series Database Connection CPU Units User s Manual W527 Terminology Terminology Term Description Column One of the information layers of each DB Refer
205. gives the debugging procedure in the startup phase Actual device environment Debugging method CPU Unit DB Check item Operation Exist Connected Connection to the DB Start the DB Connection Service in Operation Mode Check the status of the DB Connection Service and each DB Connection from Sysmac Studio Checking the DB read write and Execute DB Connection Instructions timing Check the Operation Logs i e Execution Log Debug Log and SQL Execution Failure Log including the check of connection to the DB executions of SQL statements and responses 3 20 NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function 3 6 3 Operation Phase This section gives the troubleshooting procedure in the operation phase Actual device environment Debugging method CPU Unit DB Check item Operation Exist Connected Regular check Check the event logs Check the Operation Logs i e Execution Log Debug Log and SQL Execution Failure Log Check the status of the DB Connection Service and each DB Connection from Sysmac Studio dnueis ubiseq ul Buib6ngqeq 9 je a O O D feb oO o a gt feb n D n Check the status of the DB Connection Service and each connection using a DB Connection Instruction aseud uodo 9 NJ series Database Connection CPU Units User s Manual W527 3 21
206. gram so that the DB Connection Instructions are executed after confirming the status of the DB Connection Service is Running with the _DBC_Status Run system defined variable Running flag of the DB Connection Service Status User program example IF _DBC_Status Run FALSE THEN RETURN Abort the processing because the DB Connection Service is not running END IF Execution of DB Connection Instructions Omitted after this Starting Stopping the Service by Online Operation from Sysmac Studio 7 Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Online Settings from the menu while online with an NJ series CPU Unit The following Online Settings Tab Page is displayed w Service Start Stop Shutdown v Debug Log Start Stop Nu series Database Connection CPU Units User s Manual W527 4 3 BDIMJOS UOIOBUUOD gq JO PON UNH L sainped0ig dols uels pue BDIMOS UOI NBUUOD gq 9U dols UeIS 0 MOH 2 1 7 4 Basic Operations and Status Check 4 1 3 4 4 You can start or stop the DB Connection Service by clicking a button Category Item Button Operation Service Start Stop Start Operation The DB Connection Service is started in Operation Mode Mode Start Test Mode The DB Connection Service is started in Test Mode Stop The DB Connection Service is stopped 2 To st
207. gram to an NJ series CPU Unit 3 16 NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function 3 5 2 Displaying DB Connection Instructions on Sysmac Studio The DB Connection Instructions are displayed in the DB Connection instruction category of Toolbox of Sysmac Studio Toolbox JAE gt Counter gt Data Movement gt Data Type Conversion F o1 UV e Q x o 3 3 J Q o gt a o n h D v DB Connect FB DB_Close DB_Connect DB_ControlService DB_ControlSpool DB_CreateMapping DB_Delete DB_GetConnectionStatus DB_GetServiceStatus DB_Insert DB_PutLog DB Select DB_Shutdown DB_Update oipn s DewsAS UO SUOHONSuU uonoauuon gq Bulke dsiq z s NJ series Database Connection CPU Units User s Manual W527 3 17 3 Programming the DB Connection Function 3 5 3 DB Connection Instruction Set The following set of DB Connection Instructions is supported Instruction Name Function DB_Connect Establish DB Connects to a specified DB Connection DB_Close Close DB Closes the connection with the DB Connection established by a DB_Connect Establish DB Connection instruction DB_CreateMapping Create DB Map Creates a mapping from a DB Map Variable to a table of a DB DB_Insert Insert DB Record Inserts values of a DB Map Variable to a table of the connected DB as a record DB_Update Update DB Record
208. has three statuses Closed Connected and Disconnected After the DB Connection Service is started each DB Connection enters the Closed status When the DB Connection is established in the Closed status the DB Connection enters the Connected status If the DB Connection cannot be established it remains in the Closed status When a network failure or server problem occurs in the Connected status the DB Connection enters the Disconnected status The DB Connection tries reconnection periodically in the Disconnected status The DB Connection enters the Connected status if the DB can be reconnected and remains in the Disconnected status if the DB cannot be reconnected The following table gives the details of each status uonosuuon Gq YoeE JO SNIS UOIIO UUOD E y Status Description Remarks Closed The DB is not connected Connected The DB is connected You can execute SQL statements such as INSERT and SELECT using instructions Disconnected The DB was disconnected due to a If the DB Connection enters this status during network failure server s problem or instruction execution the SQL statement is other causes spooled Reconnection is attempted periodically NJ series Database Connection CPU Units User s Manual W527 4 11 4 Basic Operations and Status Check 4 3 4 Checking the Status of each DB Connection You can use the following methods to check the status of each DB Connection Connection Monitor Table of S
209. he DB Connection Service suonon suj uonosuuo n gq was in progress e When the instruction was executed while the DB Connection Service was stopped due to an error e When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down When 32 or more DB Connection Instructions were executed at the same time Sample Programming This section gives sample programming for the following operations Get the status of the DB Connection Service when the trigger variable changes to TRUE Change the value of the Warning variable to TRUE if the number of error executions is 100 or greater i Ladder Diagram Main Variables iw Ww Q A S 09 lt re o Name Data type Initial value Comment DB_GetServiceStatus_instance DB_GetServiceStatus Instance of DB_GetServiceStatus instruction Trigger BOOL FALSE Variable used as a trigger for getting the status of the DB Connection Service 2 m S uo2 uuo gq 041U05 Operating BOOL FALSE The DB_GetServiceStatus instruction is executed when this variable is TRUE OperatingEnd BOOL FALSE This variable changes to TRUE when the DB_GetServiceStatus instruction is completed NJ series Database Connection CPU Units User s Manual W527 A 61 Appendix A Name Data type Initial value Comment RS_instance RS Instance of RS instruction MyStatus _sDBC_SERVICE_STATUS This va
210. he DB Map Variable The table specified in the DB_CreateMapping instruction does not exist in the DB One or more structure member values of the DB Map Variable cannot be converted to the corresponding column s data type One or more structure member values of the DB Map Variable exceed the valid range of the corresponding column s data type The column specified in the extraction condition does not exist in the DB s records DB_Select instruction DB_Update instruction DB_Delete instruction The extraction condition has a syntax error DB_Select instruction DB_Update instruction DB_Delete instruction The column specified in the sort condition does not exist in the DB s records DB_Select instruction The sort condition has a syntax error DB_Select instruction The user does not have the access rights to the table 5401 300C hex Spool Capacity Exceeded The SQL statement could not be stored in the Spool memory because its maximum Capacity was exceeded The DB connection failure has been continuing due to network failure or other factors The resend processing of the SQL statements stored in the Spool memory has not been executed when the Resend spool data parameter is set to Manual 5401 300E hex Invalid Extraction Condition The entered extraction condition is invalid A text string that consists
211. he Operation Log Window in Sysmac Studio 6 24 NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 6 3 6 6 4 6 2 Checking the Log with the SD Memory Card 06 Checking the Log by Transfer using FTP Client Software NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 1 Operation Logs Operation Logs are used to trace the operations of the DB Connection Service on the CPU Unit The logs are saved on the SD Memory Card mounted in the CPU Unit The following three types of Operation Logs are provided Operation Log type Description Execution Log Used to record the executions of the DB Connection Service in order to check the execution records of the DB Connection function Debug Log Used to record the contents and results of SQL executions and user specified logs for debugging SQL Execution Used to record the transmitted SQL statements and error information in order to check the Failure Log information on execution failure of SQL statements in the DB D L O O D feb e O Q Q n 6 3 NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 2 Execution Log 6 2 1 This section describes the Execution Log used to trace the executions of the DB Connection Service Overview You can check the start stop of the DB Connection Ser
212. he instruction i An Error Occurs when a Record Processing Instruction is Executed No error is detected when a mapping is created for a DB Map Variable by executing a DB_CreateMapping Create DB Map instruction The DB_Insert Insert DB Record DB_Update Update DB Record or DB_Select Retrieve DB Record instruction will result in an error When the DB cannot be connected When the specified table does not exist in the DB When a member name of the DB Map Variable does not match a column in the table When a member s data type does not match the data type of the corresponding column Q qo eo J D a o a fal faj 5 D o 5 J W D ke lt D 5 D a D i NJ series Database Connection CPU Units User s Manual W527 3 11 3 Programming the DB Connection Function 3 4 Specifying the Table and Applying 3 4 1 3 4 2 3 12 the Mapping You need to create a mapping from a DB Map Variable to the DB for each SQL type INSERT UPDATE and SELECT before you can execute a record processing instruction for inserting updating or retrieving records This section describes how to create and clear the DB mapping and restrictions DB Mapping by Executing a Create DB Map Instruction Execute a DB_CreateMapping Create DB Map instruction for mapping a DB Map Variable to the connected DB Specify the Table Name DB Map Variable and SQL Type in the DB_CreateMapping Create DB Map instruction By doing so
213. he relevant instruction was Cycle the power supply to the Write the user program so that the executed after the DB Controller start the DB relevant instruction is not executed Connection Service was shut Connection Service and then after the execution of down execute the relevant instruction DB_Shutdown instruction Or write The relevant instruction was the user program so that the executed while the shutdown relevant instruction is not executed processing of the DB Connection after shutdown is commanded from Service was in progress Sysmac Studio Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks Event name Invalid DB Connection Name Event code 5401 3003 hex Meaning The specified DB Connection Name is not set in any DB Connection settings Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end a
214. he retrieval conditions specified in the Where input variable WHERE clause with the values of a DB Map Variable specified in the MapVar input variable The records to update are retrieved according to the retrieval conditions specified in the Where input variable WHERE clause The Where input variable is expressed as a text string The text string in the Where input variable cannot consist of NULL characters 16 00 only In that case the instruction is terminated due to an error When using single quotes in the WHERE clause use the escape character Refer to the manual of the database for the format of the WHERE clause Specify the retrieval conditions by the following values in the Where input variable Example 1 Update the values of the records where the value of a specific column is equal to or greater than the specified value Update the values of records where the value of ColumnA unsigned integer is 1234 or greater ColumnA gt 1234 SQL statement to create UPDATE TableProduct SET ColumnA lt value gt ColumnB lt value gt Where ColumnA gt 1234 Example 2 Update the values of the records where the value of a specific column starts with the specified text string Update the values of records where the value of ColumnB text string starts with ABC ColumnB LIKE ABC SQL statement to create UPDATE TableProduct SET ColumnA lt value gt ColumnB
215. heck Other Functions How to Use Operation Logs Troubleshooting Appendix A Appendix B Index NJ series Database Connection CPU Units User s Manual W527 5 CONTENTS CONTENTS INtrOGUCUION tastier Aa iia Sindh iad hen eee Gade eee 1 lintendeG AUGIG NCE TEA A pais ciunthedbadebeaesieatbnadeees 1 Applicable Products i c2csccicc cgcecied soseacoiny cpedcaegsctoacdecast deez sadbedeageacdued ecard caadeatve des aietagis 1 Relevant Manuals cccccceeeceeeeecceeeeeeeeeeeeeeeaaeeeeeeeeeeceeaeaeeeeeeeeescccaeaeeeeeeeesesesseneaeeees 2 Matitial Structures itn cash Aarne ea aaaea aaa aden Garda 3 Page SUUCTUIG 2i2c6 otiveii eaea adaa a a a a it eect hee 3 Special Informati ON niai aaa aai ain eel 4 Precaution On Terminology eisni aaea aiaa ea ara atana ta a aaar a iae aa Aaaa taie 4 Sections inthis Manuals iicnti nnii aeie a EEE ce TEE Ea NR eaea 5 CONTENTS Saimen a a a e A tere irre erererer err 6 Terms and Conditions Agreement seesesssesiesesriieestiitttitinnttitntnttiinentnntntitnnnnnnnneet 11 Read and understand this Manuall cccceeeceeeeeeeneeeeeeeeeeeeeeaeeeeeeaaeeeeeeaeeeeneaa 11 Warranty Limitations of Liability 0 cc ceecececeeeeeeeeeeeeeeeeceaeeeeeaeseeeeeseaeeesaeeneaeees 11 Application Considerations 0 ccccsceeeccceceeeeeeeaeeeeeeeseaeeecaaeeeeaaeseeeeeseaeeeseaeeeenees 12 DISGIAIM ENS ios EA he vas eet tte Jew ated cata A ddetad sted AE 12 Dalety PrECAUTOMNS v
216. hen a response succeeded failed is returned to INSERT that is issued from DB Connection Service to DB after execution of a DB_Insert Insert DB Record instruction 0002 UPDATE When a response succeeded failed is returned to UPDATE that is issued from DB Connection Service to DB after execution of a DB_Update Update DB Record instruction 0003 SELECT When a response succeeded failed is returned to SELECT that is issued from DB Connection Service to DB after execution of a DB_ Select Retrieve DB Record instruction 0004 DELETE When a response succeeded failed is returned to DELETE that is issued from DB Connection Service to DB after execution of a DB_Delete Delete DB Record instruction SQL Resend 0001 INSERT When a response succeeded failed is returned to INSERT after resending the INSERT statement stored in the Spool memory 0002 UPDATE When a response succeeded failed is returned to UPDATE after resending the UPDATE statement stored in the Spool memory User specified Log 0000 to DB_PutLog When a DB_PutLog Record Operation Log 9999 Instruction Executed instruction is executed specified by the user 6 8 NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 4 Log Name Category Operation Log name DB Connection DB Connection Service Started Start Service DB Connection Service Stopped Stop DB Connection Service Shutdow
217. hen the SD Memory Card is taken out An error occurs for this instruction in the following cases Error will be TRUE e When the instruction was executed while the initialization processing of the DB Connection Service was in progress e When the instruction was executed while the DB Connection Service was stopped due to an error e When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down e When this instruction was executed with _DBC_CMD_START_TEST selected in the Cmd input variable while the service was running in Operation Mode e When this instruction was executed with _DBC_CMD_START selected in the Cmd input variable while the service was running in Test Mode A 56 NJ series Database Connection CPU Units User s Manual W527 Appendix A e When start of the DB Connection Service was commanded while the DB Connection Service was being stopped When this instruction was executed with _DBC_CMD_DEBUGLOG_ON selected in the Cmd input variable when the SD Memory Card was not available or write protected When a value that is not defined as an enumerator was specified in the Cmd input varaible When 32 or more DB Connection Instructions were executed at the same time Sample Programming This section gives sample programming for starting recording to the Debug Log when the trigger variable changes to TRUE and finishing the recording when another trigger variable
218. iable NJ series Database Connection CPU Units User s Manual W527 A 49 Appendix A DB_CreateMapping_Select_instance Execute TRUE DBConnection MyDB1 TableName Production MapVar MapVar_Select SQLType DBC _SQLTYPE_SELECT IF DB_CreateMapping_Select_instance Done TRUE THEN Operating_Connect FALSE Normal end END_IF IF DB_CreateMapping_Select_instance Error TRUE THEN Stage INT 99 Error END_IF 99 Execute the error handler Program the error handler FaultHandler_Connect according to the device FaultHandler_Connect Operating_Connect FALSE END_CASE END_IF Retrieve the records for the specified lot number from the DB Connection MyDB1 Start the sequence when the variable Trigger_Select changes to TRUE IF Trigger_Select TRUE AND LastTrigger_Select FALSE THEN OperatingStart_Select TRUE Operating_Select TRUE END_IF LastTrigger_Select Trigger_Select Sequence start processing IF OperatingStart_Select TRUE THEN Initialize the instance of the applicable DB Connection Instruction DB_Select_instance Execute FALSE MapVar MapVar_Select Create the conditions for the Where clause LotNo XXXX WhereCond_Select CONCAT LotNo UINT_TO_STRING LotNo Create the conditions for the Sort clause Sort the production completion time in descending order SortCond_Select FinishTime DESC Operati
219. ice has an error FALSE when the DB Connection Service has no error Shutdown BOOL Shutdown TRUE when the DB Connection Service has been shut down FALSE when the DB Connection Service has not been shut down 7 1 2 Errors Related to the DB Connection Service Classifications There are the following two sources of errors in the DB Connection Service Log category Classification Event source Source details User defined System log Access log event log DB Connection PLC Function DB Connection Yes No No Service Module Service DB Connection PLC Function Instruction Yes No No Instruction Module j Event Levels This section describes the operation of the DB Connection Service for each event level Event level of the error Operation Major fault All NJ series Controller control operations stop for errors in this event level Partial fault All control operations for one of the function modules in the NJ series Controller stop for errors in this event level If a partial fault level error occurs in the DB Connection Service all functions of the DB Connection Service stop Minor fault Some of the control operations for one of the function modules in the NJ series Controller stop for errors in this event level Observation Errors in the observation level do not affect NJ series Controller control operations Observations are reported in order to prev
220. icensed not sold This agreement only gives you some rights to use the software Microsoft reserves all other rights Unless applicable law gives you more rights despite this limitation you may use the software only as expressly permitted in this agreement In doing so you must comply with any technical limitations in the software that only allow you to use it in certain ways You may not disclose the results of any benchmark tests of the software to any third party without Microsoft s prior written approval reverse engineer decompile or disassemble the software except and only to the extent that applicable law expressly permits despite this limitation publish the software for others to copy rent lease or lend the software or TRANSFER TO A THIRD PARTY The first user of the software may transfer it and this agreement directly to a third party Before the transfer that party must agree that this agreement applies to the transfer and use of the software The first user must uninstall the software before transferring it separately from the device The first user may not retain any copies EXPORT RESTRICTIONS The software is subject to United States export laws and regulations You must comply with all domestic and international export laws and regulations that apply to the software These laws include restrictions on destinations end users and end use For additional information see www microsoft com exporting NJ series Datab
221. ied nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 33 Bee Guoouse qnos z 7 suondnos q 10113 2 2 2 7 Troubleshooting Event name Log Code Out of Range Event code 5401 3010 hex Meaning The value of the entered log code is outside the valid range Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction A value outside the valid range Correct the user program so that Write the user program so that the from 0 to 9999 was specified the log code is within the valid log code is within the valid range range from 0 to 9999 from 0 to 9999 Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instr
222. ies No Technical Support End of Agreement Relationship Between the Parties and Open Source You must also include a provision stating that your end users shall have no right to distribute the programs and a provision specifying us as a third party beneficiary of the agreement You are responsible for obtaining these agreements with your end users You agree to a defend and indemnify us against all claims and damages caused by your distribution of the programs in breach of this agreements and or failure to include the required NJ series Database Connection CPU Units User s Manual W527 23 Regulations and Standards 24 contractual provisions in your end user agreement as stated above b keep executed end user agreements and records of end user information including name address date of distribution and identity of programs distributed c allow us to inspect your end user agreements and records upon request and d enforce the terms of your end user agreements so as to effect a timely cure of any end user breach and to notify us of any breach of the terms Export You agree that U S export control laws and other applicable export and import laws govern your use of the programs including technical data additional information can be found on Oracle s Global Trade Compliance web site located at http Awww oracle com products export index html content html You agree that neither the programs nor any direct product there
223. ies Troubleshooting Manual Cu series Special Unit Operation Manuals for NJ series CPU Unit Introduction to NJ series Controllers Setting devices and hardware Using motion control Using EtherCAT Using EtherNet IP Using DB Connection Service Using CJ series Units gt Software settings Using motion control Using EtherCAT Using EtherNet IP Using DB Connection Service Programming Using motion control Using EtherCAT Using DB Connection Service Using CJ series Units gt Programming error processing Testing operation and debugging Using motion control Using EtherCAT Using EtherNet IP Using DB Connection Service A h Troubleshooting and managing paper errors in an NJ series Controller manuals for references according to any error that occurs Maintenance Using EtherCAT Using EtherNet IP Using CJ series Units gt 0 2 NJ series Database Connection CPU Units User s Manual W527 Manual Structure Page Structure The following page structure is used in this manual Level 2 heading Level 3 heading A step in a procedure Indicates a procedure Special information Icons indicate precautions additional information or reference information BR Manual name 4 Insta
224. ies serectet sec eceteen Hacceae chee s eres vectaete stu a E cite ei eevee lee 14 Definition of Precautionary Information ccccceeeseeceeeeeceeeeeeeeeeseeeeeseaeeesnaeeneaes 14 Precautions tor Safe USE sinana e aden tied sintered eels 15 Precautions for Correct USC cc cccceceeeeeeeeeeeeeeeeeeeeeeceeaaaeeeeeeeeeeseeeaaeeseeeeeeesesnenaaeees 16 Regulations and Standards wi c2 snien ietietiihncteee eit ete ee 17 Conformance to EC Directives cccceseeeeeeeeeeeeeeeeeee scenes ceaeeeseaeseeneeseeeesaaeeeeneeee 17 Conformance to Shipbuilding Standards cccccesceceeeeeeeeeeeeeseeeeeseeeeeeeeees 18 Software Licenses and Copyrights cc cccccceeeeseeceeeeeeeeeeeaeeeeaeeeeeaeeesaeeneneeees 18 Unit Version S a asia a a E e e a a A A a aaa a Aa a a E a aA TAEA p Ae arinaa EEE AAEE 26 OA E E E T AE E T 26 Notation of Unit Versions on Products ccccecceceeeeceeeeeeeeeeeeeeeeeeeceeeeeeceaeeeeseneeeeseeneeeeeeeaees 26 Confirming Unit Versions with Sysmac Studio c ccccceececeeeeeceeeeeeeeeeeeeeneeeeeeeeeeeseeeeeeees 26 BOES MiK aE e E E E E E EAE EA 28 TSU MINOIOQY AE E E E E AAS A E A AE ETA 29 Revision History AEE E EE AA AE E EE EEA eA ET 30 1 Introduction to the DB Connection Service ccccessssseeeeeteeeseeeeeeeeeeeeeeeees 1 1 1 1 Overview and Features ccccccecceeceeceeeeceeeeeeeeeeeeneeaeeeeeeeeeesennaeeseeeeesesenneaees 1 2 1 1 1 OVGIVICW E E E A I A AEA
225. igger_Insert TRUE AND LastTrigger_Insert FALSE THEN OperatingStart_Insert TRUE Operating_Insert TRUE END_IF LastTrigger_Insert Trigger_Insert Sequence start processing IF OperatingStart_Insert TRUE THEN Initialize the instance of the applicable DB Connection Instruction DB_Insert_instance Execute FALSE MapVar MapVar_Insert Create production data to insert MapVar_Insert Name Name MapVar_Insert LotNo UINT_TO_STRING LotNo MapVar_Insert Status Busy MapVar_Insert ProductionDate DT_TO_DATE GetTime J uW QO O 3 5 oO QO O 5 gt A 2 c QO O 3 na OperatingStart_Insert FALSE END_IF Insert production data to the DB Connection MyDB1 Set the timeout for instruction execution to 200 ms IF Operating_Insert TRUE THEN Insert records DB_Insert_instance Execute TRUE DBConnection MyDB1 MapVar MapVar_Insert TimeOut T 200ms puod9ey ga aw pdn apd ga IF DB_Insert_instance Done TRUE THEN Operating_Insert FALSE Normal end END_IF IF DB_Insert_instance Error TRUE THEN Go to the next step when the instruction is not completed within the specified time IF DB_Insert_instance ErrorlID 16 3012 THEN Operating_Insert FALSE Normal end ELSE Execute the error handler NJ series Database Connection CPU Units User s Manual W527 A 31 Appendix A Program the error handler FaultHandle
226. ile the DB Connection Service was being shut down When the DB Connection name specified in the DBConnectionName input variable is not set in any DB Connection Settings When the DBConnectionName input variable is a text string consisting of NULL characters 16 00 only When a space character is included in the text string specified for the DBConnectionName input variable e When the DBConnectionName input variable does not end in NULL e When 32 or more DB Connection Instructions were executed at the same time Sample Programming This section gives sample programming for the following operations Get the status of the DB Connection when the trigger variable changes to TRUE Change the value of the Warning variable to TRUE when the spool usage has exceeded 80 Ladder Diagram Main Variables Name Data type Initial value Comment DB_GetConnectionStatus_instance DB_GetConnectionStatus Instance of DB_GetConnectionStatus instruction Trigger BOOL FALSE Variable used as a trigger for getting the status of the DB Connection J W O O 3 5 oO QO O 5 gt na D c Q O 3 na Operating BOOL FALSE The DB_GetConnectionStatus instruction is executed when this variable is TRUE DB_GetConnectionStatus_instance OperatingEnd BOOL FALSE This variable changes to TRUE when z the DB_GetConnectionStatus instruction is completed Q RS_instance RS oa Instance of RS instruction 5
227. in the following cases Error will be TRUE When the instruction was executed when the DB Connection Service was not running When the instruction was executed while the initialization processing of the DB Connection Service was in progress When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down NJ series Database Connection CPU Units User s Manual W527 A 37 Appendix A When the value of the DBConnection input variable is invalid or the specified DB Connection is already closed When the value of the Timeout input variable is outside the valid range When the variable specified in the MapVar in out variable has not been mapped by a DB_CreateMapping instruction When the executed SQL statement resulted in an error in the DB When the DB Connection Service cannot communicate with the DB due to a network failure or other Causes When one or more SQL statements are already stored in the Spool memory When the instruction was not completed within the time specified in the TimeOut input variable When the instruction was executed before completion of the DB s processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_ Update DB_ Select or DB_ Delete instruction When 32 or more DB Connection Inst
228. ing the SD Memory Card 6 23 6 5 4 Replacement Timing of SD Memory Card 6 23 6 6 Checking the Operation LOGS ceceececeesseeeeeeeeneeeeeeeneeeeeessaeeeeeteaeeeeeeeaeaes 6 24 6 6 1 How to Check the Operation LOQS cccccceeeeeseeeeeteeesteeeeeeeeeees 6 24 6 6 2 Checking the Log on the Operation Log Window in Sysmac Studio 6 24 6 6 3 Checking the Log with the SD Memory Card cccceeeeeeeeees 6 26 6 6 4 Checking the Log by Transfer using FTP Client Software 6 26 T gt TROUBISSHOOUNG ises sonras ace nonce ee cee acs tase aaa ir eased att 7 1 7 1 Overview Of EVTOMs erionenn da A ea e bd dene oetsh DAG iadaa dea ieaie 7 2 7 1 1 How to Check for Errors cccccsccccessssececeeseeeeesesaeeessecsaeesesesaeeeeseaas 7 3 7 1 2 Errors Related to the DB Connection Service ccceeeeereees 7 5 7 2 Troubleshooting siin Na aiaeitrcr ts dined ie eae 7 7 7 2 1 Error Tabene noria ddan died e e as ds E Ea y 7 7 7 2 2 Error Descriptions x aisi iea ae etd iced cried ete 7 15 Appendix A DB Connection Instructions 0 cceeeeeeeeeeceee eee eeeeeeeeeeenneeeeeeeeeeeees A 1 A 1 DB Connection Instructions and Variables cccceceeeeeeeeeeeeeeeeeeeteeeees A 2 A 1 1 DB Connection Instruction Set cccecccceceesceeeseeeeeeesseeeesseeaeees A 2 A 1 2 Variables Used in the DB Connection InstructionS 00 A 3 DB_Connect Establish DB Connection 0 0 0
229. instructions For the timeout of instructions specify the maximum time that can be used for DB access in the takt time If you set a timeout for a DB_Insert instruction for the equipment where production data is stored into the DB using the DB_Insert instruction at the end of the takt time for example a DB Connection Instruction Execution Timeout will occur for the DB_Insert instruction when the record inserting processing to the DB is not completed in the takt time In this case the record inserting processing to the DB is executed to the end You can continue the operation without lowering the equipment performance or extending the takt time by specifying a timeout for the instruction even if execution time of DB Connection Instructions is temporarily increased When timeout is not specified DB_Insert instructionDB_Insert instruction DB_Insert instruction DB_Insert instruction ea Takt time Takt time Takt time Takt time Tt Tt Tt F 7t The takt time is extended because execution time of the DB_Insert instruction is increased When timeout is specified B 10 DB _Insert instructionDB_Insert instruction DB_Insert instruction DB_Insert instruction Timeout _ gt gt lt gt a Sra a Takt time Tt The DB_Insert instruction results in a DB Connection Instruction Execution Timeout The record inserting processing to the DB is executed to the end A Precaution
230. integer value in milliseconds is displayed DB error code Error code that is specific to DB vendor of the device to connect When a network error has occurred 0 is displayed for DB error code in some cases When 0 is displayed check the Result suoljeaiioads al 607 Bngaq 9 parameter Category User specified Log Log message Displays the text string specified in the LogMsg input variable of the DB_PutLog instruction 128 bytes max Tab separation 10 bytes in total CR LF 2 bytes 1 The system time of the CPU Unit is used for the time information 2 Category Category Characters displayed in the log DB Connection DB_ CONNECTION SQL SQL SQL Execution Result SQL_RESULT User specified Log USER NJ series Database Connection CPU Units User s Manual W527 6 15 6 How to Use Operation Logs 3 Code Category Code Operation Log recording timing decimal DB Connection 0001 DB Connection When the establishment processing of a DB Established Connection is completed succeeded failed after the establishment is commanded from the applicable instruction SQL 0001 INSERT Before the DB Connection Service sends an SQL statement after a DB_Insert Insert DB Record instruction is executed e When an SQL statement is stored in the Spool memory 0002 UPDATE Before the DB Connection Service sends an SQL statem
231. ion on the NJ series CPU Unit The DB Connection Service is available with the NJ series NJ501 11720 CPU Units Structure DB Connection Instruction variables e g DB_Insert instruction YTABLE Field1 10 TABLE Field2 20 T e g Insert a record Fieldi Fieid2 Fieid3 Field4 Field3 40 DBConnection 10 20 40 700 Field4 100 abe MapVar Server ee Relational Database NJ series NJ501 12 20 CPU Unit Oracle Database of Oracle Corporation and SQL Server of Microsoft Corporation are supported A single NJ series CPU Unit can access up to three databases on up to three servers Sysmac Studio EtherNet IP port Features No Special Unit Tool nor Middleware Required e No special Unit is required for the DB Connection function You can use the NJ series CPU Units e No special tool is required for the DB Connection function You can use Sysmac Studio The server does not need any special middleware for connection to the NJ series CPU Units Easy Access to the DB The SQL operations such as INSERT and SELECT can be easily executed No special knowledge of SQL statements is required Variables for DB access can be defined just by creating a structure for the table that you want to access You can easily control the execution timing and prepare the write values because the SQL operations can be ex
232. ion before executing a DB_Insert DB_Update or DB_ Select instruction Specify the type of SQL command for the variable to map in the SQL Type input variable For example specify _DBC_SQLTYPE_INSERT to insert the values of the DB Map Variable to the table using a DB_Insert instruction A 12 NJ series Database Connection CPU Units User s Manual W527 Appendix A Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur When the DB Connection Service was started in Test Mode this instruction is completed normally without connecting to the DB actually You can create a mapping for up to 15 DB Map Variables in all DB Connections However even if the number of DB Map Variables has not reached the upper limit an instruction error Data Capacity Exceeded will occur when any of the following conditions is met When the total number of members of structures used as data type of DB Map Variables in all DB Connections exceeds 10 000 members An error occurs fo
233. ion failure has Recover from the network failure Control from the user program like been continuing due to network below failure or other factors Check the Spool memory usage using a DB_GetConnectionStatus instruction and when the Spool memory usage has exceeded a certain value do not execute the DB_Insert nor DB_Update instructions Or check the DB Connection status using a DB_GetConnectionStatus instruction and when the status has changed to Connected resend the SQL statements stored in the Spool memory using a DB_ControlSpool instruction The resend processing of the Resend the SQL statements Check the DB Connection status SQL statements stored in the stored in the Spool memory using using a DB_GetConnectionStatus Spool memory has not been a DB_ControlSpool instruction instruction and when the status executed when the Resend after establishing the DB has changed to Connected resend spool data parameter is set to Connection again the SQL statements stored in the Manual Spool memory using a DB_ControlSpool instruction Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be ide
234. ion to be performed after the DB Connection is closed by the keep alive monitoring function is the same as the communications timeout Refer to 5 4 4 Communications Timeout for the operation NJ series Database Connection CPU Units User s Manual W527 5 21 5 Other Functions La Precautions for Correct Use The Keep Alive monitoring time is a common setting to the built in EtherNet IP port When you set the Keep Alive monitoring time confirm that the operations of the following functions in the built in EtherNet IP port are not affected before changing the value e Socket service FTP server function communications with Sysmac Studio FINS TCP 5 22 NJ series Database Connection CPU Units User s Manual W527 5 5 Other Functions This section describes the other DB Connection functions related to the backup restore function of the NJ series Controllers and verification of operation authority from Sysmac Studio 5 5 1 5 Other Functions Backup Restore Function in the DB Connection Service The backup function is used to back up the setting data in an NJ series Controller into an SD Memory Card or a computer And the restore function is used to restore the data from an SD Memory Card or a computer to the Controller This section describes the Controllers backup restore function related to the DB Connection Service The following table shows whether each data can be backed up and restored by the function
235. ion to be taken when the Debug Log has reached the maximum number of files Stop logging Default Continue logging Delete the oldest file Delete the log at recording start Set whether to delete the Debug Log contained in the SD Memory Card when recording is started Delete Default Do not delete You can record a specified log as Debug Log using a DB_PutLog Record Operation Log instruction The logs recorded by a DB_PutLog Record Operation Log instruction are called user specified log To record the user specified log set Log Type to Debug Log and specify the log code log name and log message in a DB_PutLog Record Operation Log instruction and execute the instruction Refer to Appendix DB Connection Instructions for details of the DB_PutLog Record Operation Log instruction NJ series Database Connection CPU Units User s Manual W527 6 11 9 co J oy Cc Ko e 6o7 Bnq q eu umes 9 6 How to Use Operation Logs 6 3 4 Starting Recording to Debug Log You can start recording to the Debug Log by the following methods e Online operation from Sysmac Studio e Executing a DB_ControlService Control DB Connection Service instruction Start by Online Operation from Sysmac Studio 1 Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Online Settings from
236. ions Common Input and Output Variables Used in the DB Connection Instructions DBConnection Input variable DBConnection Description DB Connection output from a DB_Connect instruction The instructions are executed for a specified DB Connection Data type DWORD Meaning DB Connection ServiceStatus gt Outpuuvariabie Meaning Data type Description Member w ServiceStatus DB Connection _sDBC_SERVICE_STATUS Structure to show the status of the DB Service Status Connection Service Q Status Service Status _eDBC_STATUS Enumeration data type to show the service status Q _DBC_STATUS_IDLE 0 Idle S _DBC_STATUS_RUNNING 1 5 Running in Operation Mode 4 _DBC_STATUS_TEST 2 S Running in Test Mode o DebugLog Debug Log Flag BOOL TRUE while the Debug Log is recorded n FALSE while recording to the Debug Log 2 is stopped z OperatingTime Operating Time TIME Time elapsed since the service was ov started D ExecCnt Number of Normal DINT Total number of times in all connections D Executions when an SQL statement was normally executed FailedCnt Number of Error DINT Total number of times in all connections Executions when an SQL statement execution failed gt SpoolDataCnt Number of Spool DINT Number of SQL statements stored in the an Data Spool memory in all connections N S ConnectionStatus D Ouiputvariable Meaning Data type Description D Member C Co
237. is cleared Members of MapVar1 variable are mapped with columns of Table1 for UPDATE Connection DBConnection Busy Tablet TableName Error MapVar1 MapVar ErrorlD _DB_SQLTYPE_UPDATE SQLType e Number of DB Map Variables for which Mapping can be Created You can create a mapping for up to 15 DB Map Variables in all DB Connections When the upper limit is exceeded an instruction error Data Capacity Exceeded will occur when a DB_CreateMapping Create DB Map instruction is executed However even if the number of DB Map Variables has not reached the upper limit an instruction error Data Capacity Exceeded will occur when the following condition is met When the total number of members of structures used as data type of DB Map Variables in all DB Connections exceeds 10 000 members 3 14 NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function Definition of DB Map Variables When a DB _Insert Insert DB Record DB_Update Update DB Record DB_ Select Retrieve k DB Record instruction is executed in a POU instance that is different from the POU instance D where the DB_CreateMapping Create DB Map instruction is executed the DB Map Variable z 2 ne h needs to be a global variable S 3 Q Q ms ee i gt 0 B oOo OD U w D gt 5D Q Qa wo I O n o h O O n O m J jes fad O m Q NJ series Database Connection CP
238. isplays a 4 digit hexadecimal code that shows the execution result e g 0x1234 0x0000 Succeeded Other than 0x0000 Failed Same code as ErrorID of DB Connection Instruction DB 16 bytes max Variable Displays a DB Connection name single byte alphanumeric characters Connection When the category is DB Connection Service or User specified Log name nothing is displayed Serial ID 10 bytes max Variable ID code given at each execution of DB_Insert DB_Update DB_Select or DB_Delete instruction Decimal code consisting of 10 digits max Possible range 0 to 2147483647 When this value exceeds 2147483647 or when the power supply to the CPU Unit is turned ON the value returns to 0 When the category is DB Connection Service DB Connection or User specified Log nothing is displayed NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs Parameter Size Description Details Variable Displays the details of the Execution Log The contents differ according to the category In the Details parameter information items are separated from each other by a tab Category DB Connection Service None Category DB Connection SQL status lt tab gt DB error code lt tab gt Error message SQL status The SQLSTATE value defined in the SQL Standards ISO IEC 9075 is displayed DB error code Error code that is specific to DB vendor of the device to connect When a network err
239. it Editor and select Production Information from the menu Model information Lotnumber Rack 0 Slot 0 Unit 3 CAIW CRM21 MODE1 Ver L3 100702 Output file Show Detail Close Simple Display Model information Lot number NJ501 1520 Ver 1 05 30810 DBCon Ver 1 00 jre7 Ver 7 04 Hardware version D FD D D Software version SYSTEM 1 05 00 33528 BOOT 20121219 IOPFP B 3 0 IOPFW D 00 Runtime 435 Rack 0 Slot 0 Unit 3 CJ1W CRM21 MODE Ver 1 3 100702 Unit revision A PCB revision AB_ Software revision EA 0 Output file Show Outline Close Detailed Display In this example Ver 1 05 is displayed next to the unit model The following items are displayed CPU Unit Unit model Unit version DB Connection Service name and version Lot number CJ series Units Unit model Unit version Lot number Rack number slot number and unit number NJ series Database Connection CPU Units User s Manual W527 27 Related Manuals Related Manuals The following manuals are related to the DB Connection Service Use these manuals for reference Manual name Cat No Model numbers Application Description NJ series CPU Unit W500 NJ501 Learning the An introduction to the entire NJ series sy
240. itialization processing of the DB Connection Service was in progress 3016 hex DB in Process The instruction was executed before completion of the DB s processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_Update DB_Select or DB_Delete instruction Function This instruction is used to delete the records that match the conditions specified in the Where input variable from the table specified in the TableName input variable The records to delete are retrieved according to the retrieval conditions specified in the Where input variable WHERE clause The Where input variable is expressed as a text string The text string in the Where input variable cannot consist of Null characters 16 00 only In that case the instruction is terminated due to an error When using single quotes in the WHERE clause use the escape character Refer to the manual of the database for the format of the WHERE clause A 40 NJ series Database Connection CPU Units User s Manual W527 Appendix A Specify the retrieval conditions in the Where input variable by the following values Example Delete the records where either of the values of the specified two columns is equal to the specified value Delete the records where the value of ColumnA unsigned integer is equal to 1000 or the value of ColumnB unsigned integer is equal to 2000 ColumnA 1000 OR Column
241. ix A 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 OperatingEnd_Connect DB_Connect_instance Error DB_CreateMapping_Select_instance Error Accept the trigger for establishing the DB Connection RS_Connect_instance Trigger_Connect _DBC_Status Run Operating_Connect 1 Establish the DB Connection named MyDatabase1 OperatingEnd_Connect DB_Connect_instance Operating_Connect DB Connect Execute Done MyDatabase1 DBConnectionName Busy Error ErrorlD DBConnection Map the variable MapVar_Select to the table Production of the DB Connection MyDB1 for the SELECT operation DB_CreateMapping_Select_instance DB_Connect_instance Done DB_CreateMapping Execute Done MyDB1 DBConnection Busy Production TableName Error MapVar_Select MapVar ErrorlD _DBC_SQLTYPE_SELECT saltype 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 Operating_Connect DB_Connect_instance Error FaultHandler_Connect EN FaultHandler_Connect DB_CreateMapping_Select_instance Error A 44 NJ series Database Connection CPU Units User s Manual W527
242. joodsjouu0D gq NJ series Database Connection CPU Units User s Manual W527 A 75 Appendix A Structured Text ST Main Variables Name Data type DB_GetConnectionStatus_instance DB GetConnectionStatus Initial value Comment Instance of DB_GetConnectionStatus instruction DB_ControlSpool_instance DB_ControlSpool Instance of DB_ControlSpool instruction Trigger BOOL FALSE Variable used as a trigger for resending the Spool data LastTrigger BOOL FALSE Variable to retain the trigger status of the previous execution Operating BOOL FALSE When this variable is TRUE the resending processing of Spool data is executed if necessary OperatingStart BOOL FALSE The initialization processing is executed when this variable is TRUE Resend BOOL MyStatus _sDBC_CONNECTION_STATUS FALSE This variable changes to TRUE when the status of the DB Connection is Connected This variable is assigned to the ConnectionStatus output variable from DB_GetConnectionStatus_instance MyDB1 DWORD This variable is assigned to the DBConnection input variable to DB_ControlSpool_instance Sample Programming Start the sequence when the Trigger variable changes to TRUE IF Trigger TRUE AND LastTrigger FALSE THEN OperatingStart TRUE Operating TRUE END_IF LastTrigger Trigger Sequence start processing IF OperatingStart TRUE THEN Initialize
243. l W527 Appendix A END_IF IF DB_PutLog_instance Error TRUE THEN Error handler Operating FALSE END_IF END_IF J uW QO O 3 5 oO QO O 5 gt A 2 c QO O 3 na 607 uogeiado piooey Bona gq NJ series Database Connection CPU Units User s Manual W527 A 83 Appendix A DB Shutdown Shutdown DB Connection Service The DB_Shutdown instruction shuts down the DB Connection Service so as to prevent losing the Operation Log data Instruction Name FB FUN Graphic expression ST expression DB_Shutdown Shutdown DB FB g DB_Shutdown_instance Execute DB_Shutdown_instance Connection Done Busy Error ErrorlD Service DB_Shutdown Execute Done Busy Error ErrorlD Note The DB_Shutdown_instance is an instance of DB_Shutdown instruction which is declared as a variable Variables Input Variables Name Valid range Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or TRUE when the instruction is being executed FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to FALSE an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF Related System de
244. l end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction Though a DB Connection Re execute the relevant Estimate the processing time of the Instruction Execution Timeout instruction from the user program DB in the server and adjust the occurred for the previous However if you execute a execution timing of the DB instruction the relevant DB_Insert or DB_Update Connection Instruction to an instruction was executed before instruction and the spool function appropriate frequency completion of the DB s is enabled you do not have to processing in the server re execute the relevant instruction because the SQL statement will be stored in the Spool memory Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code Error DEx Precautions None Remarks Event name Operation Log Disabled Event code 5401 3017 hex Meaning The log could not be recorded because the specified Operation Log is disabled Source PLC Function Module Source det
245. le can be converted to Variable can be converted to the corresponding column s data the corresponding column s data corresponding column s data type type type One or more structure member Check the structure member Write the user program so that the values of the DB Map Variable values of the DB Map Variable structure member values of the DB exceed the valid range of the Map Variable are within the valid corresponding column s data range of the corresponding type column s data type The column specified in the Check whether the column name Confirm that the column name extraction condition does not specified in the extraction specified in the extraction condition exist in the DB s records condition is correct Or check is correct Or confirm that the DB_Select instruction whether the syntax of the syntax of the extraction condition is DB_Update instruction extraction condition is correct correct DB_Delete instruction The extraction condition has a syntax error DB_Select instruction DB_Update instruction DB_Delete instruction The column specified in the sort Check whether the column name Confirm that the column name condition does not exist in the specified in the sort condition is specified in the sort condition is DB s records correct Or check whether the correct Or confirm that the syntax DB_Select instruction syntax of the sort condition is of the sort condition is correct The sort condition has a syntax corr
246. livered subject to the DOD FAR Supplement are commercial computer software and use duplication and disclosure of the programs including documentation shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement Otherwise programs delivered subject to the Federal Acquisition Regulations are restricted computer software and use duplication and disclosure of the programs including documentation shall be subject to the restrictions in FAR 52 227 19 Commercial Computer Software Restricted Rights June 1987 Oracle America Inc 500 Oracle Parkway Redwood City CA 94065 NJ series Database Connection CPU Units User s Manual W527 Regulations and Standards End of Agreement You may terminate this agreement by destroying all copies of the programs We have the right to terminate your right to use the programs if you fail to comply with any of the terms of this agreement in which case you shall destroy all copies of the programs Relationship Between the Parties The relationship between you and us is that of licensee licensor Neither party will represent that it has any authority to assume or create any obligation express or implied on behalf of the other party nor to represent the other party as agent employee franchisee or in any other capacity Nothing in this agreement shall be construed to limit either party s right to independently develop or distribute software that is functional
247. llation and Wi ring 4 3 Mounting Units 4 3 1 Connecting Controller Components The Units that make up an NJ series Controller can be connected simply by pressing the Units together and locking the sliders by moving them toward the back of the Units The End Cover is connected in the same way to the Unit on the far right side of the Controller T Join the Units so that the connectors fit exactly Hook Hook holes Connector Q 2 The yellow sliders at the top and bottom of each Unit lock the Units together Move the slide rs toward the back of the Units as shown below until they click into place Move the slidersdward the bak until they lock into plae r G Precautions for Correct Use The sliders on the tops and bottoms of the Power Supply Unit CPU Unit O Units Special I O Units and CPU Bus Units must be completely locked until they click into place after connecting the adjacent Unit connectors NJ seriesCPU Unit Hadware Usefs Manual W500 NJ series Database Connection CPU Units User s Manual W527 sun Bununow s4 SIUSUOGWUOD JE ONUOD BUIP ULOO L E Manual Structure Level 1 heading Level 2 heading r Level 3 heading Gives the current headings Page tab Gives the number of the main section This illustration is provided only as a sample It may not literally appear in this manual Manual Structure Special Information Special informa
248. lso apply to all updates you receive under your Technology Track subscription The OTN License Agreement terms below supercede any shrinkwrap license on the OTN Technology Track software CDs and previous OTN License terms including the Oracle Program License as modified by the OTN Program Use Certificate Oracle Technology Network Development and Distribution License Agreement We us and our refers to Oracle America Inc for and on behalf of itself and its subsidiaries and affiliates under common control You and your refers to the individual or entity that wishes to use the programs from Oracle Programs refers to the software product you wish to download and use and program documentation License refers to your right to use the programs under the terms of this agreement This agreement is governed by the substantive and procedural laws of California You and Oracle agree to submit to the exclusive jurisdiction of and venue in the courts of San Francisco San Mateo or Santa Clara counties in California in any dispute arising out of or relating to this agreement We are willing to license the programs to you only upon the condition that you accept all of the terms contained in this agreement Read the terms carefully and select the Accept button at the bottom of the page to confirm your acceptance If you are not willing to be bound by these terms select the Do Not Accept button and the registration process will not continue
249. lt Do not record Number of files Set the maximum number of files of the Execution Log When the maximum number of files is reached the oldest file is deleted and a new file is created 2 to 100 files Default 48 files Number of records Set the number of log records that can be contained in each Execution Log file When the maximum number of records is reached a new file is created 100 to 65536 records Default 7200 records Debug Log Number of files Set the maximum number of files of the 1 to 100 files Debug Log Default 1 file File size Set the maximum file size 1 to 100 MB When the maximum file size is exceeded or when the number of records exceeds 65 536 records in a file a new file is created Default 10 MB NJ series Database Connection CPU Units User s Manual W527 2 5 sBulljeS uoloeuu0D gq Z Z M N Li w W Q O J m oO QO n O wn D y lt O oO wn oO st J Q n 2 DB Connection Settings Category Item Description Value When the log is full Set the action to be taken when the log has Continue logging Delete the oldest reached the maximum number of files file Stop logging Default Delete the log at Set whether to delete the Debug Log Delete Default recording start contained in the SD Memory Card when lt Do not delete recording is started SQL SQL execution failure Set whether to record the SQL Executi
250. ly similar to the other party s products so long as proprietary information of the other party is not included in such software Open Source Open Source software software available without charge for use modification and distribution is often licensed under terms that require the user to make the user s modifications to the Open Source software or any software that the user combines with the Open Source software freely available in source code form If you use Open Source software in conjunction with the programs you must ensure that your use does not i create or purport to create obligations of us with respect to the Oracle programs or ii grant or purport to grant to any third party any rights to or immunities under our intellectual property or proprietary rights in the Oracle programs For example you may not develop a software program using an Oracle program and an Open Source program where such use results in a program file s that contains code from both the Oracle program and the Open Source program including without limitation libraries if the Open Source program is licensed under a license that requires any modifications be made freely available You also may not combine the Oracle program with programs licensed under the GNU General Public License GPL in any manner that could cause or could be interpreted or asserted to cause the Oracle program or any modifications thereto to become subject to the terms of the GPL
251. ments executed using the DB Connection Instructions When the Spool data is resent it is not recorded to the Debug Log To check the time and execution results of SQL statements resent from the Spool memory check the Execution Log record with the same serial ID To check the parameters of the SQL statements in that case check the log record at the time when the applicable SQL statement is spooled in the Debug Log 6 3 2 Application Procedure 6 10 Use the Debug Log according to the following procedure Step Reference 1 Set the Debug Log Refer to 6 3 3 Setting the Debug Log 2 Start recording to the Debug Log Refer to 6 3 4 Starting recording to Debug Log 3 Check the Debug Log Refer to 6 6 Checking the Operation Logs NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 3 3 Setting the Debug Log Double click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer Then set the following in the Service Setting Item Description Values Number of files Set the maximum number of files of 1 to 100 files the Debug Log Default 1 File size Set the maximum file size 1 to 100 MB When the maximum file size is exceeded or when the number of records exceeds 65 536 records in a file a new file is created Default 10 MB When the log is full Set the act
252. n Shutdown DB Connection DB Connection Established Connect DB Connection Closed Close DB Connection Disconnected Disconnect DB Connection Reestablished Reconnect SQL INSERT INSERT UPDATE UPDATE SELECT SELECT DELETE DELETE SQL Resend INSERT INSERT UPDATE UPDATE User specified DB_PutLog Instruction Executed Text string specified in the Log LogName input variable of the DB_PutLog instruction eRecord examples DB Connection Service Started 1 2012 07 24 21 29 45 267 DB_SERVICE 0001 Start 0x0000 INSERT Failed 1 2012 07 24 21 29 45 267 SQL 0001 INSERT 0x1234 DBConnection1 45TableX VarY 100 17026 e User specified Log 1 2012 07 24 21 29 45 267 USER 9876 LineA1 0x0000 ProductionStarted ce N m x la 5 o Ko Log file example D Da ol m x lt Oo 0 2012 07 2408 29 45 267 DB_SERVICE 0001 Start 0x0000 2 gt 1 2012 07 2408 31 52 002 DB_CONNECTION 0001Connect 0x0000 MyDatabase1 O 2 2012 07 2408 31 53 959 DB_CONNECTION 0001 Connect 0x0000 MyDatabase2 3 2012 07 2409 00 00 052 USER 0001 LineA1 0x0000 ProductionStarted 4 2012 07 2409 00 00 150 SQL 0001INSERT 0x0000 MyDatabase1 0 TABLE_Production Production 100 0 D 5 2012 07 2409 10 00 150 SQL 0001 INSERT 0x0000 MyDatabase1 1 TABLE Production Production 100 0 o Oo 6 2012 07 2409 20 00 151 SQL 0001INSERT 0x0000 MyDatabase1 2 TABLE Production Production 100 0 O 7 2012 07 2409 30 00 150 SQL 0001 INSERT 0x0000 MyDatabase1 3
253. n be Spooled You can estimate the number of SQL statements that can be spooled using the following formulae Number of SQL statements that can be spooled Spool capacity per DB Connection bytes Number of bytes of each SQL statement Spool capacity per DB connection bytes Capacity of the entire Soool memory 1 048 576 bytes Number of DB Connections for which the Spool function is enabled pajoods aq ued yey SJUBWA EIS JOS JO JOQUINN 04 a eWISy 0 MOH 6 1 S NJ series Database Connection CPU Units User s Manual W527 5 11 5 Other Functions 5 2 DB Connection Service Shutdown 5 2 1 5 12 Function This section describes the shutdown function of the DB Connection Service to prevent losing the Operation Log data Refer to 4 3 1 Operation Status of the DB Connection Service for the information on the operation status of the DB Connection Service Overview The DB Connection Service shutdown function hereinafter called shutdown function is used to shut down the DB Connection Service after saving the Operation Log files into the SD Memory Card Execute the shutdown function before turning OFF the power supply to the CPU Unit You can prevent losing the Operation Log data by executing the shutdown function l Precautions for Correct Use If the power supply to the CPU Unit is turned OFF without executing the shutdown function while the DB Connection Service is running the contents of the Operation Logs cannot b
254. n error in the DB 2 300C hex Spool Capacity Exceeded The SQL statement cannot be stored in the Spool memory because its v capacity is exceeded a 300E hex Invalid Retrieval Conditions The Where input variable is a text string consisting of NULL characters uW 16 00 only p 3011 hex DB Connection Disconnected Error The DB Connection Service cannot communicate with the DB due to a 9 Status network failure or other causes a 3012 hex DB Connection Instruction Execution The instruction was not completed within the time specified in the TimeOut Timeout input variable 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3014 hex Data Already Spooled The SQL statement was spooled because one or more SQL statements are already stored in the Spool memory 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress 3016 hex DB in Process The instruction was executed before completion of the DB s processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_Update DB_Select or DB_Delete instruction NJ series Database Connection CPU Units User s Manual W527 A 19 Appendix A Function This instruction is used to update the values of the records retrieved from the table mapped by a DB_CreateMapping instruction according to t
255. n is normally completed change the Resend variable to TRUE if the status of the DB Connection is Connected Operating DB_GetConnectionStatus_instance Done lt Resend _eDBC_CONNECTION_STATUS _DBC_CONNECTION_STATUS_CONNECTED MyStatus Status Nosent _eDBC_CONNECTION_STATUS _DBC_CONNECTION_STATUS_CONNECTED MyStatus Status A 74 NJ series Database Connection CPU Units User s Manual W527 Appendix A When the instruction is terminated due to an error execute the error handler for the device FaultHandler_GetConnectionStatus Program the FaultHandler_GetConnectionStatus according to the device Operating DB_GetConnectionStatus_instance Error Resend the Spool data Error handler FaultHandler_GetConnectionStatus DB_ControlSpool_instance Operating Resend DB_ControlSpool Execute Done DBConnection Busy eDBC_SPOOL_CMD _DBC_SPOOL_RESEND Cmd Error ErrorlD When the instruction is terminated due to an error change the variable Contro Spool_OK to FALSE Operating Resend DB_ControlSpool_instance Error r e When the instruction is normally completed change the variable Contro Spoo _OK to TRUE Error handler ControlSpool_OK FALSE Operating Resend DB_ControlSpool_instance Done He Error handler ControlSpool_OK J uW QO O 3 5 oO QO O 5 gt an 2 c QO O 3 an eeq joods sea D puesey
256. n use the following three methods to start or stop the DB Connection Service Starting the service automatically when the operating mode of the CPU Unit is changed to RUN mode Starting stopping the service by online operation from Sysmac Studio Executing a DB_ControlService Control DB Connection Service instruction Please note that the Run mode of the DB Connection Service cannot be changed while the service is running To change the Run mode you need to stop the DB Connection Service and then start the service again 4 2 NJ series Database Connection CPU Units User s Manual W527 4 Basic Operations and Status Check Starting the Service Automatically when Operating Mode of the CPU Unit is Changed to RUN Mode Double click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer Then set Service start in Run mode to Auto start Operation Mode or Auto start Test Mode in the Service Settings Default Auto start Operation Mode When the operating mode of the CPU Unit is changed from PROGRAM mode to RUN mode the DB Connection Service is automatically started H Precautions for Correct Use Even if you set Auto Start for the DB Connection Service you cannot execute the DB Connection Instructions until the startup processing of the DB Connection Service is completed An Instruction Execution Error will occur Therefore write the user pro
257. nction Refer to the Sysmac Studio Version 1 Operation Manual Cat No W504 for detailed operations 2 1 1 Starting Sysmac Studio 7 Install Sysmac Studio version 1 06 or higher 2 Start Sysmac Studio 2 1 2 Creating a New Project 7 Select NJ501 1320 1420 or 1520 in the Device Field of the Select Device Area EZ Offline FJ Project Properties New Proiec i Project name Author Frm Open Project Comment Type Standard Project oe Import Gq Select Device Category Controller Device NJ501 Version 1 03 ee license 2 Click the Create Button DB Connection is displayed under Host Connection Settings in the Multiview Explorer v Configurations and Setup a EtherCAT gt CPU Expansion Racks I O Map gt amp Controller Setup gt 1 Motion Control Setup amp Cam Data Settings Event Settings e Task Settings A Data Trace Settings v DB Connection S DB Connection Service Settings 9 2 NJ series Database Connection CPU Units User s Manual W527 2 DB Connection Settings 2 1 3 Setting the Built in EtherNet IP Port 1 Right click Built in EtherNet IP Port Settings under Configurations and Setup Controller Setup in the Multiview Explorer and select Edit from the menu 2 Make the TCP IP LINK FTP NTP SNMP SNMP Trap and FINS settings in the Built in EtherNet IP Port Settings Tab Page Refer to the NJU series CPU Unit Built in EtherNet IP Port User s Manual Cat No W506 fo
258. nctions 0 ec eeeceeeeeeeeeneeeeeeeaeeeeeeaeeeeeeaaes 5 19 5 4 2 tagi TIMEGE raseras rerererr re rrrcer rere E AI 5 20 5 4 3 Query Execution Timeout ceeeeeesceeeeeeeeeeeeeeeeeeseeeeeseaeeesaeeeeaees 5 20 5 4 4 Communications TiM Out c ccssccecsesseceeeeenseeeeeesaeeeessnaeeeeeseaas 5 21 5 4 5 Instruction Execution Timeout sssssssssssrrsserirssrrrrssrrrnssrrennsss 5 21 5 4 6 Keep Alive Monitoring TiMe ssssseessesresrssrrssrssrrssrresrresrrssrn 5 21 5 5 Other FUNCIONS ss cece veces vedios see dettees Ee E Aa eaaa eee E N EA adea feei 5 23 5 5 1 Backup Restore Function in the DB Connection Service 5 23 5 5 2 Operation Authority Verification in the DB Connection Service 5 24 6 How to Use Operation LOQS cccccscccceccceeeeeeeeeeeeeeeeeaeeeeeeeeeteneseseaeaaeaaeees 6 1 6 1 Operation Eoo LE EE E EE E ii Gale A eke AARNE ed 6 3 6 2 Execution LOG ix siacieteSavce aie Secale a N e Sawa 6 4 6 2 1 OVEIVIOW eE cai feees ca O ct hdtea dia doaden se uotesti E AO 6 4 6 2 2 Application ProCeure ccccccccceeeeeneteeeeneeeeeenaeeeeeeaeeeeeenaeeeeeeaaes 6 4 6 2 3 Setting the Execution LOQ ccceceeeeeceeeeeeeeeeeeeeteeeeeestaeeeeneeeeenees 6 5 6 2 4 Checking the Execution LOQ cccceeeeeeeeeeeeeeeeeseeeeeseeeeseaeeeeeeeess 6 5 6 2 5 Execution Log File Specifications ccccccsseeeeceeseeeeeeteeteneeeeees 6 5 6 3 Debug Loginin iapa hia ieee ln nhae Uinta aa agi 6 1
259. nds A communications timeout will occur When the communications timeout has occurred the instruction will be terminated due to an error DB Connection Disconnected Error Status and the DB Connection is changed to the Disconnected status In the case of DB_Insert Insert DB Record or DB_Update Update DB Record instruction the SQL statement is stored in the Spool memory If resending of Spool data and disconnection of DB Connection occur repeatedly increase the time set in the Query execution timeout parameter or review the SQL operation to make an adjustment so that the communications timeout does not occur Refer to 5 4 Timeout Monitoring Functions for timeout monitoring NJ series Database Connection CPU Units User s Manual W527 5 Other Functions 5 1 9 How to Estimate the Number of SQL Statements that Can be Spooled The number of SQL statements that can be spooled depends on the user program This section describes how to estimate the number of SQL statements that can be spooled Calculation of the Number of Bytes of each SQL Statement You can calculate the number of bytes of each SQL statement as shown below You can check the contents of SQL statements with the Debug Log Refer to 6 3 Debug Log for the information on the Debug Log Reeth SOL siatement Calculating formula of the number of bytes of cA each SQL statement DB_Insert insert into lt TableName gt 50 Number of bytes of lt TableName gt
260. nection Service Status instruction DB_GetConnectionStatus Get DB Connection Status instruction or a system defined variable i in the above figure Errors and status of the DB Connection Service are stored as an event log j Refer to 7 Troubleshooting in the above figure The logs of tracing the operations of the DB Connection Service on the CPU Refer to 6 How to Use Unit called Operation Logs k in the above figure are saved as a log file Operation Logs I in the above figure into the SD Memory Card mounted in the CPU Unit When transmission of an SQL statement failed the SQL statement is Refer to 5 1 Spool Function automatically saved into the EM Area m in the above figure When the communications are recovered the stored SQL statement is resent automatically or by executing an instruction n in the above figure NJ series Database Connection CPU Units User s Manual W527 1 7 1 Introduction to the DB Connection Service 1 3 Operation Flow of the DB Connection Service This section gives the basic operation flow The DB Connection Service is basically used according to the following flow STEP 1 Starting Sysmac Studio Belushi ae Sysmac Studio and Creating a New Project STEP 2 Creating a New Project Pororo e een Sysmac Studio and Creating a New Project STEP 3 Making the DB Connection Settings pelohlo SDE Connection Settings
261. nection Service was commanded while the DB e Connection Service was being stopped 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was Shutting Down shut down or while the DB Connection Service was being shut down s 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was 9 stopped due to an error ius 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the p DB Connection Service was in progress 8 Q NJ series Database Connection CPU Units User s Manual W527 A 55 Appendix A Function This instruction is used to start and stop the DB Connection Service and start and finish recording to the Debug Log When the DB can be connected start the DB Connection Service in Operation Mode When there is no DB for example in the course of development start the DB Connection Service in Test Mode In this case the following instructions are normally completed without accessing the DB and executing the SQL statement actually DB Connect instruction DB_CreateMapping instruction DB _Insert instruction DB_Update instruction e DB_ Select instruction e DB_ Delete instruction When the DB Connection Service is stopped the established connections are all closed When recording to the debug log is started the detailed log for each execution of DB Connection Instructi
262. ned to the DBConnection output variable from DB_Connect_instance Trigger_Connect BOOL FALSE Variable used as a trigger for establishing a DB Connection RS_Connect_instance RS Instance of RS instruction Operating_Connect BOOL FALSE The DB_Connect instruction is executed when this variable is TRUE OperatingEnd_Connect BOOL FALSE This variable changes to TRUE when the DB_Connect instruction is completed DB_CreateMapping_Insert_instance DB_CreateMapping Instance of DB_CreateMapping instruction MapVar_Insert PRODUCTION_INSERT This variable is assigned to the MapVar input variable to DB_CreateMapping_Insert_instance DB_Insert_instance DB_Insert Instance of DB_Insert instruction Name STRING 256 WORKO01 Production information Product name LotNo UINT 1234 Production information Lot number A 22 NJ series Database Connection CPU Units User s Manual W527 Appendix A Name Data type Initial value Comment Trigger_Insert BOOL FALSE Variable used as a trigger for inserting DB records RS_Insert_instance RS Instance of RS instruction Operating_Insert BOOL FALSE The DB_Insert instruction is executed when this variable is TRUE OperatingEnd_Insert BOOL FALSE This variable changes to TRUE when the DB_Insert instruction is completed DB_CreateMapping_Update_instance DB_CreateMapping Instance of DB_CreateMapping instruction MapVar_Update PRODUCTION_UPDATE This variable i
263. ng table gives the reference values for execution time of each DB Connection Instruction Conditions DB_Insert When executing an INSERT operation for 100 column record DB_Select When searching for one record from 100 000 records and retrieving 100 column data The primary key is specified for the retrieval condition Percentage of Reference value for DB type task execution Instruction instruction execution time time Average Oracle Database 11g 50 DB _Insert 16 2 ms DB_Select 37 1 ms 80 DB_Insert 49 2 ms DB_Select 101 6 ms SQL Server 2012 50 DB _Insert 20 6 ms DB_Select 34 0 ms 80 DB_Insert 70 0 ms DB_ Select 95 7 ms The following table shows the measurement conditions and items Measurement conditions ae Description Item Subitem CPU Unit Model NJ501 1520 Task composition Primary periodic task only Task period 1 ms Percentage of task execution time in the task period 80 Server Computer CPU Intel Xeon R CPU E31220 3 10 GHz 3 09 GHz Memory 8 00 GB Operating system Windows Server 2008 Standard SP2 64 bits DB type Oracle Database Express Edition 11g 11 2 0 SQL Server 2012 SQL statement to execute Record composition INT 40 columns REAL 40 columns STRING 16 16 columns DATE_AND_TIME 4 columns Operation Logs Execution Log Recorded Debug Log Stopped SQL Execution Not recorded Failure Log B 2 NJ series Databas
264. ng to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction The DB Map Variable has not Correct the user program so that Write the user program so that the been created by a the relevant instruction is executed relevant instruction is executed DB_CreateMapping instruction after the DB Map Variable is after the DB Map Variable is created by a DB_CreateMapping created by a DB_CreateMapping instruction instruction A variable that is not registered Check the input parameters of the In the input parameters of the as a DB Map Variable was relevant instruction and correct the relevant instruction specify the DB specified in MapVar user program Connection specified in the The DB Connection specified in DB_CreateMapping instruction and the relevant instruction is the DB Map Variable created by different from the one specified the DB_CreateMapping instruction at the execution of DB_CreateMapping instruction Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4
265. ngStart_Select FALSE END_IF A 50 NJ series Database Connection CPU Units User s Manual W527 Retrieve the records from the DB Connection MyDB1 Timeout is not monitored for the instruction execution IF Operating_Select TRUE THEN Retrieve records DB_Select_instance Execute TRUE DBConnection MyDB1 Where WhereCond_ Select Sort SortCond_Select MapVar MapVar_Select IF DB_Select_instance Done TRUE THEN lf two or more records were retrieved delete the older records IF DB_Select_instance SelectedCnt gt 1 THEN Request_Delete TRUE END_IF Operating_Select FALSE Normal end END_IF IF DB_Select_instance Error TRUE THEN Error handler Program the error handler FaultHandler_Select according to the device FaultHandler_Select Operating_Select FALSE END_IF END_IF Delete the records other than the latest one from the DB table Start the sequence when the variable Trigger_Delete changes to TRUE IF Request_Delete TRUE AND LastRequest_Delete FALSE THEN OperatingStart_Delete TRUE Operating_Delete TRUE END_IF LastRequest_Delete Request_Delete Sequence start processing IF OperatingStart_Delete TRUE THEN Initialize the instance of the applicable DB Connection Instruction DB_Delete_instance Execute FALSE Create the conditions for the Where clause delete the records other than the latest one WhereCond_Delete
266. nnectionStatus DB Connection _sDBC_CONNECTION Structure to show the status of a DB Connection D Status _STATUS Status Connection Status _eDBC_CONNECTION Enumeration data type to show the status of a _STATUS DB Connection D _DBC_CONNECTION_STATUS_CLOSED 0 Closed O _DBC_CONNECTION_STATUS_CONNECTED 1 9 Connected z _DBC_CONNECTION_STATUS_DISCONNECTED 2 2 Disconnected Disconnected due to a network failure while the DB is connected gt ConnectedTime Connected Time TIME Total time when the DB is connected DisconnectedTime Disconnected TIME Total time when the DB is disconnected due to 2i Time an error 9 ExecCnt Number of Normal DINT Number of times when an SQL statement was Executions executed normally in the DB Connection A 3 NJ series Database Connection CPU Units User s Manual W527 Appendix A A 4 Output variable Member FailedCnt Meaning Number of Error Executions Data type DINT Description Number of times when an SQL statement execution failed in the DB Connection DBRespTime DB Response Time TIME Time since an SQL statement is sent from the CPU Unit until the SQL execution result is returned from the CPU Unit when an SQL statement is executed This is stored only when a normal response is returned from the DB If an instruction execution timeout occurred the DB Response Time is not stored when the instruction execution is completed i e when
267. nnees B 2 B 1 1 Reference Values for Execution Time of DB Connection Instructions B 2 B 1 2 How to Measure Execution Time of DB Connection Instructions B 3 B 1 3 Guideline for System Service Execution Time Ratio c B 4 B 1 4 Checking the System Service Execution Time Ratio 005 B 4 B 2 Execution Time of DB Connection Instructions ccccccccsssseseccceecessesseaeeeeeeeeesseeseas B 6 B 2 1 Restrictions to Execution Time of DB Connection Instructions B 6 B 2 2 Impact of Operation Log Recording on Execution Time of DB CONNECTION Instructions ccccecceseessececeeeeecseseaaeceeeeseeeseaeaeseeeeeenss B 8 B 2 3 How to Measure DB Response Time cceeeseeeeeeenneeeeeenaeeeeeeaes B 9 B 2 4 Ensuring Equipment Performance Takt Time by Monitoring Instruction Execution Timeout cceeeceeceeeeeeeeeeeeenaeeeeeeeeeeeeeeees B 10 NJ series Database Connection CPU Units User s Manual W527 B 1 Appendix B B 1 Task Design Procedure This section describes the task design procedure for using the DB Connection function Refer to the NU series CPU Unit Software User s Manual Cat No W501 for task and system service operation specifications of the NJ series Controllers B 1 1 Instructions Reference Values for Execution Time of DB Connection The DB Connection Instructions are function block type of instructions that are executed over multiple task periods The followi
268. nstruction truction when the value of the Execute input variable is evaluated regardless of the value of the Execute input variable Therefore write the user program so that the value of the SendStatus output variable is read before evaluating the value of the Execute input variable of the DB Connection Instruction in the first cycle of the operation The DB Connection Instruction is not executed if the Execute input variable is already TRUE at the operation start You need to change the Execute input variable to FALSE to execute the instruction 5 18 NJ series Database Connectio n CPU Units User s Manual W527 5 Other Functions 5 4 Timeout Monitoring Functions This section describes timeout monitoring for the DB Connection Service 5 4 1 Timeout Monitoring Functions The following figure shows the types of timeouts that can be monitored CPU Unit Server User program DB Connection Service DB Connection herNet IP Instruction DB_Insert Relational database c DBConnection MapVar Function name Setting range Description Reference Login timeout 1 to 60 seconds Time until the DB Connection Service Refer to 2 2 2 DB Default 10 seconds detects a login failure due to a communications failure between DB Connection Service and DB or server s problem Connection Settings Query execution 1 to 600 seconds timeout a in
269. nt SendStatus When the instruction is terminated due to an error execute the error handler for the device FaultHandler_Update Program the FaultHandler_Update according to the device Operating_Update DB_Update_instance Error Go to next step when the instruction is not completed within the specified time IF DB_Insert_instance ErrorlD 16 3012 THEN RETURN ENDIF Error handler FaultHandler_Update Close the DB Connection MyDB1 Check the completion of the DB_Close instruction DB_Close_instance Done OperatingEnd_Close DB_Close_instance Error Accept the trigger for closing the DB Connection J W O O 3 5 oO QO O 5 gt D 2 G QO O 3 na RS_Close_instance Operating_Close Trigger_Close as RS Ap Set Q1 OperatingEnd_Close Reset Close the DB Connection MyDB1 DB_Close_instance Operating_Close DB Close Execute Done DBConnection Busy puod9ey ga aw pdn apd ga Error ErrorlD When the instruction is terminated due to an error execute the error handler for the device FaultHandler_Close Program the FaultHandler_Close according to the device Operating_Close DB_Close_instance Error i FaultHandler_Close EN FaultHandler_Close NJ series Database Connection CPU Units User s Manual W527 A 27 Appendix A Structured Text ST Main Variables
270. ntified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks 7 32 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name Invalid Extraction Condition Event code 5401 300E hex Meaning The entered extraction condition is invalid Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction A text string that consists of a Enter a text string that specifies Enter a text string that specifies the NULL 16 00 character only the extraction condition in the extraction condition in the Where was specified in the Where input Where input variable input variable variable Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identif
271. nts The same methods are used for all events This allows you to see what errors have occurred and find corrections for them with the same methods for the entire range of errors that is managed i e CPU Unit EtherCAT slaves and CJ series Units Only Sysmac devices are supported DB in the server NS series PT EtherNevIP Troubleshooter aL NJ series CPU Unit AT DB Connection Service Y WRL Built in EtherCAT pon Troubleshooting functions port CJ series Units gt i i Bullt in EtherNev iP iA Sysmac Studio EtherCAT EtherCAT E 1 amp z rpe ae all al el al Bo Bea H i l TDO OF Error management range for NJ series Controller You can use the troubleshooting functions of Sysmac Studio or the Troubleshooter on an NS series PT to quickly check for errors that have occurred and find corrections for them This manual describes the errors that originate in the DB Connection Service Refer to the NJ series Troubleshooting Manual Cat No W503 for specific corrections when errors occur and for troubleshooting information on the entire NJ series Controller For information on errors that occur when DB Connection Instructions are executed refer to Appendix DB Connection Instructions NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting 7 1 1 How to Check for Errors You can check to see if an error has occurred with the following methods
272. o Insert DB lt ColumnName1 gt Number of bytes of lt ColumnName1 gt 8 Record lt ColumnName2 gt 2 Number of bytes of lt ColumnName2 gt T lt ColumnName3 gt 2 Number of bytes of lt ColumnName3 gt Ss lt ColumnNameN gt 2 Number of bytes of lt ColumnNameN gt 2 values lt Value1 gt lt Value2 gt Number of bytes of lt Value1 gt g lt Value3 gt lt ValueN gt 2 Number of bytes of lt Value2 gt 2 Number of bytes of lt Value3 gt 2 Number of bytes of lt ValueN gt DB_Update update lt TableName gt set 45 Number of bytes of lt TableName gt Update DB lt ColumnName1 gt lt Value1 gt 3 Number of bytes of lt ColumnName1 gt Record lt ColumnName2 gt lt Value2 gt Number of bytes of lt Value1 gt lt ColumnNameN gt lt ValueN gt 5 Number of bytes of lt ColumnName2 gt where lt RetrievalCondition gt Number of bytes of lt Value2 gt 5 Number of bytes of lt ColumnName3 gt Number of bytes of lt Value3 gt 5 Number of bytes of lt ColumnNameN gt Number of bytes of lt ValueN gt Number of bytes of lt RetrievalCondition gt Text strings of SQL statements are handled as UTF 8 One byte is used for each single byte alphanumeric character and multiple bytes are used for each multi byte character Three bytes are used for each Japanese character as a guide Calculation of the Number of SQL Statements that Ca
273. o do and what not to do to ensure safe usage of the product A Precautions for Correct Use Indicates precautions on what to do and what not to do to ensure proper operation and performance NJ series Database Connection CPU Units User s Manual W527 Precautions for Safe Use Precautions for Safe Use Refer to the following manuals for precautions for safe use e NJ series CPU Unit Hardware User s Manual Cat No W500 e NJ series CPU Unit Software User s Manual Cat No W501 e Sysmac Studio Version 1 Operation Manual Cat No W504 NJ series Database Connection CPU Units User s Manual W527 15 Precautions for Correct Use Precautions for Correct Use This section describes the precautions for correct use in the DB Connection Service Refer to the following manuals for other precautions for correct use e NJ series CPU Unit Hardware User s Manual Cat No W500 e NJ series CPU Unit Software User s Manual Cat No W501 e Sysmac Studio Version 1 Operation Manual Cat No W504 e When the Spool function is enabled the DB Connection Service uses EM Bank No 9 to 18 E9_00000 to E18_ 32767 Please design the system so that EM Bank No 9 to 18 are not used for other purposes because the Spool data is corrupted if used 16 NJ series Database Connection CPU Units User s Manual W527 Regulations and Standards Regulations and Standards Conformance to EC Directives i Applicable Directives e EMC Directives e
274. oducts will be free from defects in materials and workmanship for a period of twelve months from the date of sale by Omron or such other period expressed in writing by Omron Omron disclaims all other warranties express or implied Limitations OMRON MAKES NO WARRANTY OR REPRESENTATION EXPRESS OR IMPLIED ABOUT NON INFRINGEMENT MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OF THE PRODUCTS BUYER ACKNOWLEDGES THAT IT ALONE HAS DETERMINED THAT THE PRODUCTS WILL SUITABLY MEET THE REQUIREMENTS OF THEIR INTENDED USE Omron further disclaims all warranties and responsibility of any type for claims or expenses based on infringement by the Products or otherwise of any intellectual property right Buyer Remedy Omron s sole obligation hereunder shall be at Omron s election to i replace in the form originally shipped with Buyer responsible for labor charges for removal or replacement thereof the non complying Product ii repair the non complying Product or iii repay or credit Buyer an amount equal to the purchase price of the non complying Product provided that in no event shall Omron be responsible for warranty repair indemnity or any other claims or expenses regarding the Products unless Omron s analysis confirms that the Products were properly handled stored installed and maintained and not subject to contamination abuse misuse or inappropriate modification Return of any Products by Buyer must be approved in writing by
275. of will be exported directly or indirectly in violation of these laws or will be used for any purpose prohibited by these laws including without limitation nuclear chemical or biological weapons proliferation Disclaimer of Warranty and Exclusive Remedies THE PROGRAMS ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND WE FURTHER DISCLAIM ALL WARRANTIES EXPRESS AND IMPLIED INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT IN NO EVENT SHALL WE BE LIABLE FOR ANY INDIRECT INCIDENTAL SPECIAL PUNITIVE OR CONSEQUENTIAL DAMAGES OR DAMAGES FOR LOSS OF PROFITS REVENUE DATA OR DATA USE INCURRED BY YOU OR ANY THIRD PARTY WHETHER IN AN ACTION IN CONTRACT OR TORT EVEN IF WE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OUR ENTIRE LIABILITY FOR DAMAGES HEREUNDER SHALL IN NO EVENT EXCEED ONE THOUSAND DOLLARS U S 1 000 No Technical Support Our technical support organization will not provide technical support phone support or updates to you for the programs licensed under this agreement Restricted Rights If you distribute a license to the United States government the programs including documentation shall be considered commercial computer software and you will place a legend in addition to applicable copyright notices on the documentation and on the media label substantially similar to the following NOTICE OF RESTRICTED RIGHTS Programs de
276. oller operations Administrator Designer Maintainer Operator Observer Displaying the Operation Logs OP OP OP OP NP Clearing the Operation Logs OP OP OP NP NP Starting stopping the DB OP OP NP NP NP Connection Service Shutting down the DB Connection OP OP NP NP NP Service Starting stopping the Debug Log OP OP VR NP NP Clearing the Spool data OP OP NP NP NP DB connection test Administrator Designer Maintainer Operator Observer Communications test OP OP OP NP NP NJ series Database Connection CPU Units User s Manual W527 How to Use Operation Logs eae DB Connection Service This section describes how to use the Operation Logs for tracing the operations of the 6 1 Operation LOGS APAE eaten eve tees A T eaters 6 3 6 2 Ex cutlomLOg EAEE E EE E Goren tetas Ra eee eee 6 4 6 2 1 OVGIVICW 3 tibet hoi at ealn ited palit anit ihe iule 6 4 6 2 2 Application Procedure cceeecsceeeeesneeeeeeneeeeeenaeeeeeeeaeeeseeaeeeeeeaaes 6 4 6 2 3 Setting the Execution LOQ ccccceesceeceeeceeeeeeeeeeeeeeeeeseaeeeteaeennees 6 5 6 2 4 Checking the Execution LOQ ccccccceeceeeeeeeeeseeseeeeeseeeeesaaeeeenees 6 5 6 2 5 Execution Log File Specifications eenen ereere 6 5 6 3 DODUG LOG ccccivctecedehavctectent E EA E keke 6 10 6 3 1 OVE RVI W sects stat Aces operate a Semen les eee cebu Giada tea 6 10 6 3 2 Application Procedi Ends sereine i ene Ekra eae ai e ekk 6 10 6 3 3 Setting the Debug LOG
277. ollowing table gives the reference values for execution time of the first DB Connection Instruction after the power supply to the CPU Unit is turned ON Reference value for fe DB type Instruction wee Measurement condition instruction execution time Oracle Database DB_Insert 124 ms When executing an INSERT operation for 11g 100 column record DB_ Select 175 ms When searching for one record from 100 000 records and retrieving 100 column data SQL Server DB_Insert 70 ms When executing an INSERT operation for 2012 100 column record DB_ Select 233 ms When searching for one record from 100 000 records and retrieving 100 column data Percentage of task execution time 50 The primary key is specified for the retrieval condition Countermeasures B 6 NJ series Database Connection CPU Units User s Manual W527 Appendix B Measure the execution time of each DB Connection Instruction in reference to B 1 2 How to Measure Execution Time of DB Connection Instructions lf the execution time of a DB Connection Instruction exceeds the acceptable range of the equipment take the following actions 1 Set a timeout for the DB Connection Instruction Refer to B 2 4 Ensuring Equipment Performance Takt Time by Monitoring the Instruction Execution Timeout for details 2 Execute a dummy DB_Insert instruction once after executing the DB_CreateMapping instruction as a preparation for starting the actual operation
278. on Record Execution log Failure Log lt Do not record default Failure Log Number of files Set the maximum number of files of the 2 to 100 files SQL Execution Failure Log When the maximum number of files is reached the oldest file is deleted and a new file is created Default 50 files File size Set the maximum file size When the maximum file size is exceeded or when the number of records exceeds 65 536 records in a file a new file is created 1 to 100 MB Default 10 MB 1When a DB Connection Instruction is executed the DB Connection Service actually accesses the DB 2When a DB Connection Instruction is executed the DB Connection Service does not actually access the DB but the instruction will end normally as if it was executed EN Additional Information You can calculate the capacity of the Operation Log files that are stored on the SD Memory Card If the SD Memory Card often runs out of space please decrease the values of the following settings Execution Log Size of each record 256 bytes x Number of records x Number of files Debug Log File size x Number of files SQL Execution Failure Log File size x Number of files 2 6 NJ series Database Connection CPU Units User s Manual W527 2 DB Connection Settings 2 2 2 DB Connection Settings This section describes how to add and rename a DB Connection and also describes the DB Connection setting procedure and items
279. on Q a Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition DBConnectionName DB STRING 17 bytes max including Specify a DB Connection Connection the final NULL character name set on Sysmac Name Studio 7 D ep Output Variables D EEE lt ae O Name Meaning Data type Valid range Unit Description yA Done Done BOOL TRUE or TRUE when the instruction is normally a FALSE completed 5 Busy Executing BOOL TRUE or TRUE when the instruction is being Q FALSE executed o Error Error BOOL TRUE or TRUE when the instruction is terminated w FALSE due to an error 5 ErrorlD Error Code WORD 16 0000 to Contains the error code when an error z 16 FFFF occurs ConnectionStatus Connection _SDBC_CONNECTION Depends on Shows the status of the connection 5 Status _STATUS the data type specified in the DBConnectionName input 2 variable lt O oO eA v f 2 NJ series Database Connection CPU Units User s Manual W527 A 65 Appendix A Related System defined Variables Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used _EIP_EtnOnlineSta Related Error Codes Error code Meaning Description 0406 hex Illegal Data Position Specified The DBConnectionName input variable is a text string consisting of NULL characters 16 00 only 0410 hex Text String Format Error A space character is in
280. onnected due to an error Source PLC Function Module Source details DB Connection Detection When a DB Service timing Connection Instruction is executed or when Spool data is resent Error attributes Level Minor fault Recovery Automatic Log category System recovery Effects User program Continues Operation Not affected System defined Variable Data type Name variables _DBC_ Status _sDBC_STATUS DB Connection Service Status Cause and Assumed cause Correction Prevention correction The power supply to the server is Check the server status and start it Check the server status and start it OFF properly properly The DB is stopped in the server The Ethernet cable connector is Reconnect the connector and Connect the connector securely disconnected make sure it is mated correctly The Ethernet cable is broken Replace the Ethernet cable None Noise Implement noise countermeasures Implement noise countermeasures if there is excessive noise if there is excessive noise Attached Attached information 1 DB Connection Name information Precautions None Remarks 7 20 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name DB Connection Service Started Event code 95300000 hex Meaning The DB Connection Service was started Source PLC Function Module Source details DB Connection Detection When the DB Service timing
281. ons such as transmitted SQL statements is output to the Debug Log file in the SD Memory Card Precautions for Correct Use e Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing e Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur e When starting the DB Connection Service confirm that the value of _DBC_Status dle is TRUE and then execute this instruction If this instruction is executed while the DB Connection Service is being initialized an error DB Connection Connection Service Initializing will occur e It is impossible to change the DB Connection Service from Operation Mode to Test Mode and vice versa while the DB Connection Service is running Stop the service before changing the Run mode e The recording status of the Debug Log i e whether or not to record the Debug Log is held after the DB Connection Service is stopped and started again e Besides this instruction recording to the Debug Log is stopped in the following cases e When a DB_ Shutdown instruction is executed e When the power supply to the CPU Unit is turned OFF e W
282. ons and creation procedure of the structure data type Overview You create a user defined structure data type on Sysmac Studio based on the data type of the table to access Register all or some of the columns of the table as structure members 3 2 1 ne N QO D je Q w 0p c Q i gt O je w lt O D Each structure member name and data type must match the corresponding column name and data type of the table Same structure Data type definition on Sysmac Studio Table definition of the DB DB Connection Instruction y Product Lot Total Success Failed Name No Count Count Count Structure data type for DB access M Q L Z wd et m for each SQL NJ series CPU Unit DB When creating a variable called DB Map Variable you specify the structure as its data type 3 2 2 Specifications of Structure Data Type for DB Access Item Specifications Structure name You can specify any name for the structures Offset specification for structure members Specify NJ for Offset Type Structure members Register all or some of the columns of the table as members Structure member name Define the same name as the corresponding column of the table The names are case sensitive Structure member s data type Define a data type that matches the data type of the correspondin
283. ontained in the DB Map Variable in the order specified by the sort conditions When the sort conditions are not specified the output order to the DB Map Variable depends on the specifications of the DB type to connect When using single quotes in the WHERE and SORT clauses use the escape character Refer to the manual of the database for the format of the WHERE and SORT clauses Specify the retrieval conditions by the following values in the Where input variable Example 1 Retrieve the values of the records where the value of a specific column is equal to or greater than the specified value Retrieve the values of records where the value of ColumnA unsigned integer is 1234 or greater ColumnA gt 1234 SQL statement to create SELECT FROM TableProduct Where ColumnA 1234 A 36 NJ series Database Connection CPU Units User s Manual W527 Appendix A Example 2 Retrieve the records where the values of specific two columns are within the specified range Retrieve the records where the value of ColumnA unsigned integer is bigger than 1000 and the value of ColumnB unsigned integer is smaller than 2000 ColumnA gt 1000 AND ColumnB lt 2000 SQL statement to create SELECT FROM TableProduct Where ColumnA gt 1000 AND ColumnB lt 2000 Specify the sort conditions in the Sort input variable by the following values Example Retrieve the re
284. or DB_Delete Execute the instruction again after Execute the relevant instruction instruction was executed when the resend processing of the SQL when no SQL statements are one or more SQL statements statements stored in the Spool stored in the Spool memory were already stored in the Spool memory is completed memory Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks Event name DB Connection Service Initializing Event code 54013015 hex Meaning The instruction could not be executed because the initialization processing of the DB Connection Service is in progress Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables _DBC_Status _sDBC_STATUS DB Connection Service Status Cause and Assumed cause Correction Prevention c
285. or a TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or TRUE when the instruction is being executed FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to FALSE an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF NJ series Database Connection CPU Units User s Manual W527 A 11 w uW O O 5 5 oO QO O 5 D o c QO O 5 a dew ga 21319 Buiddey yjerequn ga Appendix A Related System defined Variables _EIP_EtnOnlineSta Online Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used Related Error Codes Error code Meaning Description 0400 hex Input Value Out of Range A value that is not defined as an enumerator was specified in the SQL Type input variable 0406 hex Illegal Data Position Specified The TableName input variable is a text string consisting of NULL characters 16 00 only 0410 hex Text String Format Error A space character is included in the text string specified for the TableName input variable 041B hex Data Capacity Exceeded The maximum number of mappings that can be created in all DB Connections i e 15 DB Map Variables is exceeded 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were execute
286. or has occurred 0 is displayed for DB error code in some cases When 0 is displayed check its SQL status Error message The error message is displayed from the first character within the record size i e 256 bytes Category SQL Table name lt tab gt DB Map Variable name lt tab gt DB response time lt tab gt DB error code Table name and DB Map Variable name A maximum of 60 bytes from the beginning are displayed DB Map Variable name Variable name specified in the MapVar input variable Nothing is displayed for DELETE DB response time An integer value in milliseconds is displayed DB error code Error code that is specific to DB vendor of the device to connect When a network error has occurred 0 is displayed for DB error code in some cases When 0 is displayed check the Result parameter a N m x 2 5 o Ko Category SQL Resend DB response time lt tab gt DB error code DB response time An integer value in milliseconds is displayed DB error code Error code that is specific to DB vendor of the device to connect When a network error has occurred 0 is displayed for DB error code in some cases When 0 is displayed check the Result parameter Category User specified Log Log message Displays the text string specified in the LogMsgq input variable of the DB_PutLog instruction 128 bytes max suoneoioeds aji4 607 uonnoexy S Z 9 Tab 10 bytes in total separation CR LF 2 b
287. ord a user specified log set Log Type to Execution Log and specify the log code log name and log message in a DB_PutLog Record Operation Log instruction and execute the instruction Refer to Appendix DB Connection Instructions for details of the DB_PutLog Record Operation Log instruction D N m x 2 fj 5 o Ko 6 2 4 Checking the Execution Log Refer to 6 6 Checking the Operation Logs for how to check the Execution Log 6 2 5 Execution Log File Specifications This section describes the specifications of Execution Log files Each Execution Log file is composed of multiple records Each record is expressed in one line The maximum number of records to be contained in each Execution Log file is set in Sysmac Studio The size of each record is 256 bytes max The following table shows the file name and type 6o7 uonnoexy y Buas g Z 9 File name File type DB_ExecutionLog log Latest log file of the log DB_ExecutionLog_ year_month_date_hours_minutes_seconds_milliseconds log Previous log files Example DB_ExecutionLog_20120724220915040 log DB_ExecutionLog fjc Log control file The system time of the CPU Unit is used for the time information included in the file name The files are stored in the following directory of the SD Memory Card e Log files packages DB_Connection ExecutionLog Log control file packages DB_Connection System NJ series Database Connection
288. orrection The relevant instruction was Execute the relevant instruction Execute the relevant instruction executed during the initialization after the operation status of the after confirming the operation processing of the DB Connection DB Connection Service changes status of the DB Connection Service to Running or Idle Service with the _DBC_Status system defined variable Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks 7 36 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name DB in Process Event code 5401 3016 hex Meaning The instruction could not be executed because the DB is under processing in the server Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction wil
289. ot be specified Array specification Array can be specified for SELECT Array cannot be specified for INSERT nor UPDATE An instruction error will occur for DB_CreateMapping Create DB Map instructions Refer to 3 3 3 Restrictions on DB Map Variables for details 1 The DB Map Variables cannot be used in any function POU because the DB_CreateMapping Create DB Map instruction is a function block type of instruction 3 10 NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function 3 3 3 Restrictions on DB Map Variables This section describes the restrictions on DB Map Variables Array Specification for Data Type of DB Map Variables by SQL Type Whether you can specify a structure array for DB Map Variables depends on SQL type The following table shows the details SQL type Specifying a structure array for DB Map Variable INSERT Not possible UPDATE SELECT Possible giqeven dew ga e Bupealp s e j Mapping Cannot be Created for a DB Map Variable Mapping cannot be created for a DB Map Variable in the following cases The DB_CreateMapping Create DB Map instruction ends in an error When the data type of the DB Map Variable is not a structure When a derivative data type is contained in structure members of the DB Map Variable When a structure array is specified for a DB Map Variable though INSERT or UPDATE is specified for the SQL type in t
290. ot be started The operation status of the DB Connection Service is changed to Error Stop System defined Variable Data type Name variables _DBC_Status _sDBC_STATUS DB Connection Service Status Cause and Assumed cause Correction Prevention correction The power supply to the Transfer the DB Connection Do not turn OFF the power supply Controller was interrupted during settings again from Sysmac to the Controller during a download a download of the DB Studio of the user program or the Connection settings Controller Configurations and Setup The DB Connection settings are Do not interrupt the power supply not correct because the power to the Controller during a Clear All supply to the Controller was Memory operation interrupted during a Clear All Memory operation The DB Connection settings are Do not interrupt the power supply not correct because the power to the Controller during a Restore supply to the Controller was operation interrupted during a Restore operation Non volatile memory failed If the error persists even after you None make the above correction replace the CPU Unit Attached None information Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 19 Be Guoouse qnol z suondnos q 10113 2 2 2 7 Troubleshooting Event name DB Connection Disconnected Error Event code 85100000 hex Meaning The DB Connection was disc
291. paration 10 bytes in total CR LF 2 bytes 1 The system time of the CPU Unit is used for the time information 2 Category Category Characters displayed in the log SQL Execution Failed SQL_FAIL Spooled SPOOL Status Error STATUS_ERROR 3 Code Category Code Operation Log recording timing decimal SQL 0001 INSERT When execution of an SQL statement issued from DB Connection Execution 0002 UPDATE Service to DB failed due to a DB caused factor Failed 0003 SELECT 0004 DELETE Spooled 0001 INSERT When an SQL statement is stored in the Spool memory because 0002 UPDATE a failure occurred in information exchange between DB Connection Service and DB 6 20 NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs Category Code Operation Log recording timing decimal Status Error 0001 INSERT When the DB Connection Service detected an error and could 0002 UPDATE not send an SQL statement When a failure occurred in information exchange between DB Connection Service and DB when spooling is disabled When an SQL statement cannot be stored in the Spool memory because the Spool capacity is insufficient as a failure occurred in information exchange between DB Connection Service and DB 0003 SELECT When the DB Connection Service detected an error and could 0004 DELETE not send an SQL statement When a
292. pe Valid range Unit Default Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition Cmd Command eDBC_CMD _DBC_CMD_START 1 0 Specify the command to Start the service in Operation Mode execute DBC_CMD_START_TEST 2 Start the service in Test Mode _DBC_CMD_STOP 3 Stop the service _DBC_CMD_DEBUGLOG_ON 4 Start recording to Debug Log _DBC_CMD_DEBUGLOG_OFF 5 Finish recording to Debug Log i Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or Se TRUE when the instruction is being executed FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to FALSE an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF A 54 NJ series Database Connection CPU Units User s Manual W527 Appendix A Related System defined Variables System defined Name Data Valid range Unit Description variables type _DBC_ Status Idle DB Connection BOOL TRUE or FALSE TRUE when the operation status of the DB Service Idle Status Connection Service is Idle Otherwise FALSE _DBC_Status Run DB Connection BOOL TRUE or FALSE TRUE when the DB Connection Service is Service Running started in Operation Mode or Test Mode Status FALSE when the DB Connection Se
293. pecified The DB Connection Name Connection DB Connection specified in the Name Name is not set DBConnectionName input in any DB variable of the relevant s Connection instruction is wrong settings The DB Connection Name set in the DB Connection settings is wrong 54013004hex DB The DB rejected The user name or password Connection the connection set in the DB Connection S Rejected settings is wrong 7 10 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event code Event name Meaning Assumed cause keve Reference Maj Prt Min Obs Info 54013005hex DB Failed to A server does not exist for Connection connect to the the specified IP address or Failed DB the specified host name The power supply to the server is OFF The DB is stopped in the S server The Ethernet cable connector is disconnected The Ethernet cable is broken 54013006hex DB A same name The relevant instruction was Connection DB Connection executed when a s Already is already same name DB Connection Established established was already established 54013007hex Too Many DB The number of The relevant instruction was Connections DB Connections executed when the that can be maximum number of DB s established at Connections that can be the same time is established at the same time exceeded were already established 54013008hex Invalid DB The specified Th
294. pecify the time to detect timeout T 0 05s to T 180s When T 0s is specified timeout is not monitored In out Variables Name Data type Valid range Description MapVar DB Map Structure Depends on Specify the DB Map Variable mapped by a Variable Structure the data type DB_CreateMapping instruction array entire array NJ series Database Connection CPU Units User s Manual W527 A 34 Appendix A l Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or TRUE when the instruction is normally FALSE completed Busy Executing BOOL TRUE or TRUE when the instruction is being executed FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to FALSE an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF RecCnt Number of DINT 0 to 65535 Contains the number of records that were Records retrieved to the DB Map Variable SelectedCnt Number of DINT 0 to Total number of records retrieved according to Retrieved 2147483647 the retrieval conditions Records Related System defined Variables _EIP_EtnOnlineSta Online Data type Description Status of the communications function of the built in EtherNet IP port TRUE Can be used FALSE Cannot be used Related Error Codes Error code Meaning Description 0400 he
295. power OFF or shutdown processing of the CPU Unit the Execution Log recorded in the internal buffer will be lost 6 2 2 Application Procedure 6 4 Use the Execution Log according to the following procedure Step Reference 1 Set the Execution Log Refer to 6 2 3 Setting the Execution Log 2 Check the Execution Log Refer to 6 6 Checking the Operation Logs NJ series Database Connection CPU Units User s Manual W527 6 How to Use Operation Logs 6 2 3 Setting the Execution Log Double click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer Then set the following in the Service Setting Item Description Values Execution log Set whether to record the Execution Log Record Default Do not record Number of files Set the maximum number of files of the Execution Log 2 to 100 files When the maximum number of files is reached the Default 48 oldest file is deleted and a new file is created Number of records Set the number of log records that can be contained in 100 to 65536 records each Execution Log file Default 7200 When the maximum number of records is reached a new file is created You can record a specified log as Execution Log using a DB_PutLog Record Operation Log instruction The logs recorded by a DB_PutLog Record Operation Log instruction are called user specified log To rec
296. prevent data loss of Operation Logs Precautions for Correct Use Execution of this instruction is continued until processing is completed even if the value of Execute changes to FALSE or the execution time exceeds the task period The value of Done changes to TRUE when processing is completed Use this to confirm normal completion of processing e Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur The DB Connection Instructions cannot be executed during and after execution of this instruction When a DB Connection Instruction is executed it will be terminated due to an error Be sure to execute this instruction before you turn OFF the power supply to the CPU Unit If the power supply is turned OFF without executing this instruction the Operation Logs will not be saved but lost error occurs for this instruction in the following cases Error will be TRUE When the instruction was executed while the initialization processing of the DB Connection Service suoljonujsu uonosuuo n gq was in progress When the instruction was executed while the stopping processing of the DB Connection Service was in progress e When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down When 3
297. r are displayed Cancel The file list is displayed again Note 2 It takes time to upload the log file because the file size is big Do you want to continue Yes Click a button Yes The specified file is uploaded from the Controller and displayed No The file list is displayed again Clear Button The selected Operation Log is cleared in the Controller A confirmation message is displayed Operatic Are you sure to clear the execution log in the controller Y N i p N Q a gt D Q a Q a gt D m O Q e a gt D O O D je r e m m 0 Q e 5 i lt n 3 je oO ie 2 NJ series Database Connection CPU Units User s Manual W527 6 25 6 How to Use Operation Logs 6 6 3 6 6 4 6 26 When you click the Yes Button the selected log is cleared e Execution Log Tab Page Execution Log is cleared in the Controller e Debug Log Tab Page Debug Log is cleared in the Controller SQL Execution Failure Log Tab Page SQL Execution Failure Log is cleared in the Controller Checking the Log with the SD Memory Card Remove the SD Memory Card from the CPU Unit and insert it into a computer Then check the contents of the logs on Microsoft Excel or a text editor Checking the Log by Transfer using FTP Client Software You can transfer the log files using the FTP Server function via the Ethernet network and check the contents on Microsoft
298. r more SQL stored in the statements were already Spool memory stored in the Spool memory s ADB Select or DB_Delete instruction was executed when one or more SQL statements were already stored in the Spool memory 54013015hex DB The instruction The relevant instruction was Connection could not be executed during the Service executed initialization processing of Initializing because the the DB Connection Service initialization s processing of the DB Connection Service is in progress 54013016hex DB in Process The instruction Though a DB Connection could not be Instruction Execution executed Timeout occurred for the because the DB previous instruction the s is under relevant instruction was processing in the executed before completion server of the DB s processing in the server NJ series Database Connection CPU Units User s Manual W527 7 13 BHunooyssqnol Z Z aN age 10113 1 2 2 7 Troubleshooting Event code Event name Meaning Assumed cause pave Reference Maj Prt Min Obs Info 54013017hex Operation Log The log could Though Execution Log was Disabled not be recorded specified in the LogType because the input variable the Execution specified Log is disabled s Operation Logis Though Debug Log was disabled specified in the Log Type input variable recording to the Debug Log is stopped 7 14 NJ series Database Connection CPU Units User s Manual
299. r of axes is different ES Additional Information The Operation Logs cannot be backed up nor restored by the Backup Restore operation If you want to keep the Operation Log data after replacement of the CPU Unit insert the used SD Memory Card to the restore destination CPU Unit after completion of the Restore operation NJ series Database Connection CPU Units User s Manual W527 5 23 suoloun 19410 S S BOINIOS UOI DBUUOD gq eu ul UONOUN a10 sey dnyoeg S S 5 Other Functions 5 5 2 Operation Authority Verification in the DB Connection Service 5 24 This function is used to restrict the online operations that can be performed on the CPU Unit from Sysmac Studio according to the operation rights This section describes the operation authority verification function related to the DB Connection Service Refer to the NJ series CPU Unit Software User s Manual Cat No W501 and the Sysmac Studio Version 1 Operation Manual Cat No W504 for details of the operation authority verification function The functions authorities and operation restrictions that require verification in the DB Connection Service are given below OP Operation possible VR Verification required for each operation NP Operation not possible Monitoring status Administrator Designer Maintainer Operator Observer DB Connection Service Monitor OP OP OP OP OP Connection Monitor Table OP OP OP OP OP Contr
300. r the detailed settings pue olpnis oewshs Bues L Z 109 01g M N L uea When you use the DB Connection Service the following port numbers are used in the built in EtherNet IP port Do not set them for the other purposes Refer to the NJ series CPU Unit Built in EtherNet IP Port User s Manual Cat No W506 for the port numbers commonly used in the NJ501 CPU Units Application UDP TCP System used 9800 to 9819 HOd dIA0N19443 uNg 94 BuN S E L Z NJ series Database Connection CPU Units User s Manual W527 2 3 2 DB Connection Settings 2 2 DB Connection Settings You need to make the initial DB Connection settings before executing the DB Connection Service Please make the settings of the entire DB Connection Service and each DB Connection This section describes the DB Connection Service settings and DB Connection settings 2 2 1 DB Connection Service Settings Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Edit from the menu v Configurations and Setup da EtherCAT gt CPU Expansion Racks VO Map gt amp Controller Setup gt lt 2 Motion Control Setup amp Cam Data Settings gt Event Settings F Task Settings F Data Trace Settings v Host Connection Settings v DB Connection DB Connection Service ssi DB Connection Settings v Programmin
301. r this instruction in the following cases Error will be TRUE When the instruction was executed when the DB Connection Service was not running When the instruction was executed while the initialization processing of the DB Connection Service was in progress When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down When the value of the DBConnection input variable is invalid or the specified DB Connection is already closed When the TableName input variable is a text string consisting of NULL characters 16 00 only When a space character is included in the text string specified for the TableName input variable When the data type of the variable specified in the MapVar input variable is not a structure When a derivative data type is included as a member of the structure variable specified in the MapVar input variable When the DB Map Variable specified in the MapVar input variable is a structure array though INSERT or UPDATE is specified for the SQL Type When a value that is not defined as an enumerator was specified in the SQLType input variable When the executed SQL statement resulted in an error in the DB When the DB Connection Service cannot communicate with the DB due to a network failure or other causes When the maximum number of mappings tha
302. rNet IP are trademarks of ODVA e The SD and SDHC logos are trademarks of SD 3C LLC SD e Oracle and Java are registered trademarks of Oracle Corporation and or its affiliates in the USA and other countries Other company names and product names in this document are the trademarks or registered trademarks of their respective companies Introduction Introduction Thank you for purchasing an NJ series CPU Unit This manual contains information that is necessary to use the Database Connection Service with the NJ series CPU Unit Hereinafter the Database Connection Service is called DB Connection Service Please read this manual and make sure you understand the functionality and performance of the NJ series CPU Unit before you attempt to use it in a control system Keep this manual in a safe place where it will be available for reference during operation Intended Audience This manual is intended for the following personnel who must also have knowledge of electrical systems an electrical engineer or the equivalent e Personnel in charge of introducing FA systems e Personnel in charge of designing FA systems e Personnel in charge of installing and maintaining FA systems e Personnel in charge of managing FA systems and facilities For programming this manual is intended for personnel who understand the programming language specifications in international standard IEC 61131 3 or Japanese standard JIS B3503 Applic
303. r_Insert according to the device FaultHandler_Insert Operating_Insert FALSE END_IF END_IF END_IF Update the records in the DB Connection MyDB1 when the variable Trigger_Update changes to TRUE Start the sequence when the variable Trigger_Update changes to TRUE IF Trigger_Update TRUE AND LastTrigger_Update FALSE THEN OperatingStart_Update TRUE Operating_Update TRUE END_IF LastTrigger_Update Trigger_Update Sequence start processing IF OperatingStart_Update TRUE THEN Initialize the instance of the applicable DB Connection Instruction DB_Update_instance Execute FALSE MapVar MapVar_Update Create production data to update MapVar_Update Status OK MapVar_Update FinishTime GetTime Create the conditions for Where clause LotNo XXXX AND Status Busy WhereCond CONCAT LotNo UINT_TO_STRING LotNo AND Status Busy OperatingStart_Update FALSE END_IF Update production data in the DB Connection MyDB1 Set the timeout for instruction execution to 200 ms IF Operating_Update TRUE THEN Update records DB_Update_instance Execute TRUE DBConnection MyDB1 MapVar MapVar_Update Where WhereCond TimeOut T 200ms IF DB_Update_instance Done TRUE THEN Operating_Update FALSE Normal end END_IF A 32 NJ series Database Connection CPU Units User s Manual W527 Appendix A IF DB_Update
304. r_Insert according to the device Operating_Insert DB_Insert_instance Error Sar Go to next step when the instruction is not completed within the specified time IF DB_Insert_instance ErrorlID 1643012 THEN RETURN ENDIF Close the DB Connection Trigger_Close TRUE Error handler FaultHandler_Insert Update the records in the DB Connection MyDB1 when the variable Trigger_Update changes to TRUE Check the completion of the DB_ Update instruction DB_Update_instance Done OperatingEnd_Update DB_Update_instance Error Accept the trigger for updating DB records RS_Update_instance Trigger_Update Operating_Update OperatingEnd_Update Create production data to update Create the conditions for Where clause Operating_Update Create production data to update MapVar_Update Status OK t MapVar_Update FinishTime GetTime Create conditions for Where clause LotNo XXXX AND Status Busy WhereCond CONCAT LotNo 1 UINT_TO_STRING LotNo AND Status Busy A 26 NJ series Database Connection CPU Units User s Manual W527 Appendix A Update production data in the DB Connection MyDB1 Set the timeout for instruction execution to 500 ms DB_Update_instance Operating_Update DB_Update Execute Done MyDB1 DBConnection Busy MapVar_Update MapVar Error WhereCond Where ErrorlD T 500ms TimeOut RecC
305. rce details DB Connection Detection When the DB Service timing Connection Service is started Error attribute Level Minor fault Recovery Error reset Log category System Effects User program Continues Operation Not affected System defined Variable Data type Name variables None ii Cause and Assumed cause Correction Prevention correction The user application made an Check for writing from the user Do not write to the Spool memory invalid writing to the Spool application to the Spool memory area from the user application memory area Correct the user application and then execute the Clear Spool Data operation Attached None information Precautions None Remarks 7 16 NJ series Database Connection CPU Units User s Manual W527 7 Troubleshooting Event name Execution Log Save Failed Event code 14D20000 hex Meaning Failed to save the Execution Log to the SD Memory Card Source PLC Function Module Source details DB Connection Detection Continuously Service timing Error attributes Level Minor fault Recovery Error reset Log category System Effects User program Continues Operation Not affected System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction An SD Memory Card is not Insert an SD Memory Card Insert an SD Memory Card inserted The SD Memory Card is not the Replace the SD Memory Card with Use an SD or SDHC ca
306. rd correct type of card an SD or SDHC card The format of the SD Memory Format the SD Memory Card with Use a formatted SD Memory Card is not correct Sysmac Studio Card Also do not remove the SD Memory Card or turn OFF the power supply while the SD BUSY indicator is lit The SD Memory Card is Remove write protection from the SD Make sure that the SD Memory write protected Memory Card Card is not write protected The capacity of the SD Memory Replace the SD Memory Card for Use an SD Memory Card that Card is insufficient one with sufficient available space has sufficient available space The SD Memory Card is If none of the above causes applies Do not remove the SD Memory damaged replace the SD Memory Card Card or turn OFF the power supply while the SD BUSY indicator is lit Do not remove the SD Memory Card while the SD PWR indicator is lit Replace the SD Memory Card periodically according to the write life of the SD Memory Card Attached Attached information 1 Error Details information 0001 hex An SD Memory Card is not inserted 0002 hex The SD Memory Card is damaged the format of the SD Memory Card is not correct or the SD Memory Card is not the correct type of card 0003 hex The SD Memory Card is write protected 0302 hex The capacity of the SD Memory Card is insufficient the SD Memory Card is damaged or failed to save a file to the SD Memory Card due to other factors Precautions You can change the error level to the obse
307. reate DB Map ccccccsseseseseeeee 11 DB_CreateMapping Create DB Map instruction 3 9 Registration and Attributes of DB Map Variables 3 10 DBA DOlOte wis a sensei odes sis eena ede dedevustas soveaeds 3 18 DB Delete Delete DB Record cccccsssessesseescesecesceseeees 40 DB_GetConnectionStatus cccccccccccssssscscscsesesssseseeeeees 3 18 DB _GetConnectionStatus Get DB Connection Status 66 DB _GetConnectionStatus Get DB Connection Status Instruction oneen n told theres cee EE ee 4 14 DB_GetServiceStatus cccccceccccccccsssssssecceesssssseseesees 3 18 DB_GetServiceStatus Get DB Connection Service Status Seuss a veadechingca E A A E OE 61 DB Insert asst o AETA 3 2 3 18 DB Insert Insert DB Record 0 cccceesessesseesceseseseeseeees 14 DB Insert Insert DB Record instruction 0 c08 5 2 DB Putopisi ua eT E e aici 3 18 DB_PutLog Record Operation Log ccccccccsecseseseseneee 79 DBO Sele Ct EAEE SE E 3 2 3 18 DB Select Retrieve DB Record e cceecsescesseescesecescesecees 35 DB_Shutdown 0 cccceccccccccesesssccecccesessececsceseessesseseeecees 3 18 DB _ Shutdown Shutdown DB Connection Service 85 DB pd ates sensau ie E arasi 3 2 3 18 DB_Update Update DB Record cccccccsessesceseesesseseees 18 DB_Update Update DB Record instruction 5 2 Debug Looe iscsi TAE E E E E EE A 29 DisGOnniect Od tine sscccisaccicsscaeesstdeneiaccaeeatedeese
308. riable is assigned to the ServiceStatus input variable to DB_GetServiceStatus_instance Warning BOOL FALSE This variable changes to TRUE when the number of error executions is 100 or greater GetServiceStatus_OK BOOL FALSE This variable changes to TRUE when the DB_GetServiceStatus instruction is completed normally Sample Programming Change the value of the variable Warning to TRUE when the number of error executions is 100 or greater Check the completion of the DB_GetServiceStatus instruction DB_GetServiceStatus_instance Done OperatingEnd DB_GetServiceStatus_instance Error Accept the trigger RS_instance Trigger Operating gg RS _ 1 Set Q1 OperatingEnd Reset1 Get the status of the DB Connection Service DB_GetServiceStatus_instance Operating DB_GetServiceStatus Execute Done Busy Error ErrorlD ServiceStatus MyStatus When the instruction is normally completed change the variable Warning to TRUE if the number of error executions is 100 or greater Operating DB_GetServiceStatus_instance Done E e E Warning DINT 100 GetServiceStatus_OK MyStatus FailedCnt When the instruction is terminated due to an error change the variable Warning to FALSE Operating DB_GetServiceStatus_instance Error Error handler GetServiceStatus_OK FALSE A 62 NJ series Database Connection CPU Units User s Manual W527 S
309. rinrnsreennnes 5 19 5 4 1 Timeout Monitoring Functions eecceeeeeeeeeeeeeeeeeeeeeneeeeeeneeeerene 5 19 5 4 2 LOGI TIMEOUT us a eee edhe de ce ee E Er EERE KA SE EEK teteenincs 5 20 5 4 3 Query Execution TimeOut 0 ccccssccccessseceeessneeeeesseeeseesseeeeeeaaes 5 20 5 4 4 Communications TIM OUt ccccssececessseceeeseseeeecessueeeessseeeessaaes 5 21 5 4 5 Instruction Execution Timeout ssseesessseerrsserrssrrrnssrrrrssrrrnssrns 5 21 5 4 6 Keep Alive Monitoring Time ccccceeeseeeeeeeeeeeeeeeneeeeeenaeeeeeeaaes 5 21 5 5 Other FuNnCtlOnSs2 0 Ata oaa ate ai vee ee Basia eee 5 23 5 5 1 Backup Restore Function in the DB Connection Service 5 23 5 5 2 Operation Authority Verification in the DB Connection Service 5 24 5 1 NJ series Database Connection CPU Units User s Manual W527 5 Other Functions 5 1 Spool Function This section describes spooling of unsent SQL statements in the DB Connection Service 5 1 1 Overview When a failure occurred in information exchange between DB Connection Service and DB the unsent SQL statements are stored in a memory area and resent when the problem is solved You can set whether to enable or disable the Spool function for each DB Connection 5 1 2 Spooling System The following figure shows the spooling system CPU Unit Server Program DB Connection DB Connection Service Instruction DB_Insert 1 Failure Relational Database
310. rmation When a DB_CreateMapping Create DB Map instruction is executed to create a mapping for a DB Map Variable it is not checked whether the structure members match the table s columns In this case the DB_Insert Insert DB Record DB_Update Update DB Record or DB_ Select Retrieve DB Record instruction will result in an error NJ series Database Connection CPU Units User s Manual W527 3 9 giqeven dew ga e upea s E g re w W D lt a D n S gt a J W D ke U gt a 3 Programming the DB Connection Function 3 3 2 Registration and Attributes of DB Map Variables You can specify the following variable types and attributes for DB Map Variables Item Available type settings Restrictions Registration of variables Global variable Local variable for a program Local variable for a function block A local variable for a function cannot be specified Attributes Variable name Any Refer to the NU Series CPU Unit Software User s Manual Cat No W501 for the restrictions on the variable names and other program related names Data Type Structure data type for DB access Refer to 3 2 Creating a Structure Data Type AT Any Retain Any Initial Value Any Constant Any This attribute cannot be specified for SELECT A compiling error will occur for DB_ Select Retrieve DB Record instructions Network Publish Any Edge This attribute cann
311. rmation by itself is not sufficient for a complete determination of the suitability of the Product in combination with the end product machine system or other application or use Buyer shall be solely responsible for determining appropriateness of the particular Product with respect to Buyer s application product or system Buyer shall take application responsibility in all cases NEVER USE THE PRODUCT FOR AN APPLICATION INVOLVING SERIOUS RISK TO LIFE OR PROPERTY WITHOUT ENSURING THAT THE SYSTEM AS A WHOLE HAS BEEN DESIGNED TO ADDRESS THE RISKS AND THAT THE OMRON PRODUCT S IS PROPERLY RATED AND INSTALLED FOR THE INTENDED USE WITHIN THE OVERALL EQUIPMENT OR SYSTEM Programmable Products Omron Companies shall not be responsible for the user s programming of a programmable Product or any consequence thereof Disclaimers 12 Performance Data Data presented in Omron Company websites catalogs and other materials is provided as a guide for the user in determining suitability and does not constitute a warranty It may represent the result of Omron s test conditions and the user must correlate it to actual application requirements Actual performance is subject to the Omron s Warranty and Limitations of Liability i Change in Specifications Product specifications and accessories may be changed at any time based on improvements and other reasons It is our practice to change part numbers when published ratings or features are
312. rror in the DB When the DB Connection Service cannot communicate with the DB due to a network failure or other causes When one or more SQL statements are already stored in the Spool memory When the SQL statement cannot be spooled because the Spool capacity is exceeded When the instruction was not completed within the time specified in the TimeOut input variable When the instruction was executed before completion of the DB s processing for the DB Connection Instruction Execution Timeout that occurred for the previous DB_Insert DB_Update DB_ Select or DB_Delete instruction When 32 or more DB Connection Instructions were executed at the same time Sample Programming Refer to the sample programming that is provided for the DB_Update instruction suoljonujsu uonosuuo gq J W 5 D p10094 gq Hasut NJ series Database Connection CPU Units User s Manual W527 A 17 Appendix A DB_Update Update DB Record The DB_Update Update DB Record instruction updates the values of a record of a table with the values of a DB Map Variable Instruction Name FB FUN DB_Update Update DB FB Record Graphic expression DB_Update_instance DB_Update Execute Done DBConnection Busy MapVar Error Where ErrorlD TimeOut RecCnt SendStatus ST expression DB_Update_instance Execute DBConnection MapVar Where TimeOut Done Busy Error ErrorlD RecCnt SendStatus Note The DB_Updat
313. rror status refer to the NJ series Instructions Reference Manual Cat No W502 Checking with System defined Variables You can use the error status variables and status variables in the system defined variables to check for errors that have occurred in the DB Connection Service Error Status Variables You can check for errors in each function module of the NJ series Controller with error status variables The following variables show the error status of the PLC Function Module Variable name Data type Meaning Function _PLC_ErrSta WORD PLC Function Module Gets the collective error status of all error Error Status status for the PLC Function Module 7 4 NJ series Database Connection CPU Units User s Manual W527 Status Variables 7 Troubleshooting Variable name Data type Meaning Function _DBC_ Status sDBC_STAT US DB Connection Service Status Shows the status of the DB Connection Service Run BOOL Running Flag TRUE while the DB Connection Service is running FALSE while the DB Connection is not running Test BOOL Test Mode TRUE while the DB Connection Service is running in Test Mode FALSE while the DB Connection Service is not running in Test Mode Idle BOOL Idle TRUE while the DB Connection Service is idle FALSE while the DB Connection Service is not idle Error BOOL Error Flag TRUE when the DB Connection Serv
314. ructions were executed at the same time Sample Programming Refer to the sample programming that is provided for the DB_ Delete instruction A 38 NJ series Database Connection CPU Units User s Manual W527 Appendix A DB_ Delete Delete DB Record The DB_ Delete instruction deletes the records that match the conditions from a specified table Instruction Name FB FUN Graphic expression ST expression DB_Delete Delete DB FB DB Delete instance DB_Delete_instance Execute Record DBConnection TableName DB_Delete Where TimeOut Done Busy Error ErrorlD RecCnt Execute Done DBConnection Busy TableName Error Where ErrorlD TimeOut RecCnt Note The DB_Delete_instance is an instance of DB_Delete instruction which is declared as a variable iw w S Variables i 8 Input Variables 5 Os 5 Name Meaning Data type Valid range Unit Default Description gt Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition O DBConnection DB Connection DWORD 16 00000000 to 16 0000 Specify the DB Connection established 5 16 FFFFFFFF 0000 by a DB_Connect instruction TA TableName Table Name STRING Depends on the 7 Specify a table name in the DB data type Where Retrieval STRING 1 986 bytes max e Specify a text string that expresses Conditions including the final retrieval conditions WHERE clause z NULL character W
315. ructure Data Type for DB Access 0 60 3 3 3 2 3 How to Create a Structure Data Type for DB ACCESS e 3 6 3 3 Creating a DB Map Variable cc ececceeseeseeeeeeeeeeeeeenneeeeeeeneeeesennaeeeeeeeaaeees 3 9 3 3 1 DB Map Variables and DB Mapping cccsceceeeeeeeeeeeeeeeeeeees 3 9 3 3 2 Registration and Attributes of DB Map Variables 0 cceee 3 10 3 3 3 Restrictions on DB Map Variables ccc eceseeeeesteeeeeeeneeeeeeaaes 3 11 3 4 Specifying the Table and Applying the Mapping 3 12 3 4 1 DB Mapping by Executing a Create DB Map Instruction 3 12 3 4 2 Clearing the Mapping of DB Map Variables c cceeeeeeeeees 3 12 3 4 3 Restrictions on DB Mapping cceeecceceeeeeeeeeeeeeeseaeeesaeeeenees 3 13 3 5 Programming and Transfer ccececeeseneeeeeeeeeeeeeeeneaeeeeseaeeeetenaeeeeeneaeeeeee 3 16 3 5 1 Programming the DB Connection Service 3 16 3 5 2 Displaying DB Connection Instructions on Sysmac Studio 3 17 3 5 3 DB Connection Instruction Set c ccceccceceeeeeeeeceeeeeseeeeeesaeeeenees 3 18 3 5 4 System defined Variables cccccccecseeceeeeeeeeeeeeeeeseeeeseaeeeeeeeees 3 19 3 5 5 Simulation Debugging of DB Connection Instructions 3 19 3 5 6 Transferring the DB Connection Settings and User Program 3 19 3 6 Debugging in Design Startup and Operation Phases cceeeeeeeees 3 20
316. rvation Remarks NJ series Database Connection CPU Units User s Manual W527 7 17 Be Guoouse qnos 2 2 suondnos q 10113 2 2 2 7 Troubleshooting Event name SQL Execution Failure Log Save Failed Event code 14D3 0000 hex Meaning Failed to save the SQL Execution Failure Log to the SD Memory Card Source PLC Function Module Source details DB Connection Detection Continuously Service timing Error attributes Level Minor fault Recovery Error reset Log category System Effects User program Continues Operation Not affected System defined Variable Data type Name variables None m Cause and Assumed cause Correction Prevention correction An SD Memory Card is not Insert an SD Memory Card Insert an SD Memory Card inserted The SD Memory Card is not the Replace the SD Memory Card with Use an SD or SDHC card correct type of card an SD or SDHC card The format of the SD Memory Format the SD Memory Card with Use a formatted SD Memory Card Card is not correct Sysmac Studio Also do not remove the SD Memory Card or turn OFF the power supply while the SD BUSY indicator is lit The SD Memory Card is Remove write protection from the Make sure that the SD Memory write protected SD Memory Card Card is not write protected The capacity of the SD Memory Replace the SD Memory Card for Use an SD Memory Card that has Card is insufficient one with sufficient available space
317. rvice is stopped _DBC_Status Test DB Connection BOOL TRUE or FALSE TRUE when the DB Connection Service is Service Test Mode started in Test Mode Status FALSE when the DB Connection Service is stopped _DBC_Status Shutdown DB Connection BOOL TRUE or FALSE TRUE when the operation status of the DB Service Shutdown Connection Service is shutdown Otherwise Status FALSE Related Error Codes UO Error code Meaning Description 2 0400 hex Input Value Out of Range A value that is not defined as an enumerator was specified in the Cmd 2 input variable T 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same Same Time time 5 1400 hex SD Memory Card Access Failure This instruction was executed with _DBC_CMD_DEBUGLOG_ON 2 selected in the Cmd input variable when the SD Memory Card was not i available 2 1401 hex SD Memory Card Write protected This instruction was executed with _DBC_CMD_DEBUGLOG_ON 5 selected in the Cmd input variable when the SD Memory Card was write protected 3001 hex DB Connection Service Run Mode Change This instruction was executed with _DBC_CMD_START_TEST Failed selected in the Cmd input variable while the service was running in Operation Mode 2 This instruction was executed with _DBC_CMD_START selected in the Cmd input variable while the service was running in Test Mode Start of the DB Con
318. ry because the SQL Execution Error may occur again when the SQL statement is resent NJ series Database Connection CPU Units User s Manual W527 5 Other Functions j Spooling Execution Conditions SQL statements are spooled in the following cases When an applicable instruction is executed the SQL statement cannot be sent due to a network failure When an applicable instruction is executed the response from the DB cannot be received due to a network failure When an applicable instruction is executed the DB is stopped due to a server s problem or other causes When an applicable instruction is executed one or more SQL statements are already stored in the Spool memory When an applicable instruction is executed a DB Connection Instruction Execution Timeout occurs La Precautions for Correct Use uonoun4 joods G The following error codes are applicable to the spooling execution conditions when the instructions end in an error When the instructions end in an error with other error codes the SQL statement is not stored in the Spool memory 3011 hex DB Connection Disconnected Error Status 3012 hex DB Connection Instruction Execution Timeout 3014 hex Data Already Spooled 3016 hex DB in Process e If an instruction error SQL Execution Error occurs the transmitted SQL statement itself can be the cause of the SQL Execution Error Therefore the SQL statement is not stored in the Spool memory because the SQL Exe
319. s Name Data type Initial value Comment DB_PutLog_instance DB_PutLog Instance of DB_PutLog instruction Trigger BOOL FALSE Variable used as a trigger for recording the user specified log LastTrigger BOOL FALSE Variable to retain the trigger status of the previous execution Operating BOOL FALSE When this variable is TRUE recording of the user specified log is executed OperatingStart BOOL FALSE The initialization processing is executed when this variable is TRUE RecipeCode UDINT 1234678 Recipe code used in the log message Msg STRING 256 Log message to record Sample Programming Start the sequence when the variable Trigger changes to TRUE IF Trigger TRUE AND LastTrigger FALSE THEN OperatingStart TRUE Operating TRUE END_IF LastTrigger Trigger Sequence start processing IF OperatingStart TRUE THEN Initialize the instruction instance DB_PutLog_instance Execute FALSE Create the log message Msg CONCAT Production Start RecipeCode UDINT_TO_STRING RecipeCode OperatingStart FALSE END_IF IF Operating TRUE THEN Record the log message into the Execution Log DB_PutLog_instance Execute TRUE LogType _DBC_LOGTYPE_EXECUTION LogCode 100 LogName Production Order LogMsg Msg IF DB_PutLog_instance Done TRUE THEN Normal end processing Operating FALSE A 82 NJ series Database Connection CPU Units User s Manua
320. s Controller that matches the column names in Refer to 3 2 Creating a the DB table a in the above figure Section 3 2 2 will help you match the Structure Data Type data types between the NJ series Controllers and database 2 Create a variable called DB Map Variable using the structure created in Step Refer to 3 3 Creating a DB 1 b in the above figure Map Variable 3 Start the DB Connection Service c in the above figure Refer to 4 7 Run Mode of Specify the Run mode of the DB Connection Service according to the following the DB Connection Service conditions and Start Stop Procedures When the DB is connected Select the Operation Mode When the DB does not exist or not connected Select the Test Mode 4 Use a DB_Connect instruction to establish a DB Connection This checks the Refer to 4 2 IP address or name of the server and log on credentials Establishing Closing a DB Connection 5 Use a DB_CreateMapping instruction to connect to a table using the DB Map Refer to 3 4 Specifying the Variable and apply the mapping called DB mapping d in the above Table and Apply the figure Mapping 6 Use DB_Insert DB_Update and DB_Select instructions to execute the insert Refer to 3 5 Programming update retrieve record processing e in the above figure and Transfer When the DB Connection Service is set to the Operation Mode the SQL statements are sent f in the above figure 1 6
321. s a in the DB Map Variable Map Variable when writing the user DB Map Variable program A non structure variable was Specify a structure variable for the specified as a DB Map Variable DB Map Variable A structure array variable was Specify a structure variable for the specified as a DB Map Variable DB Map Variable for INSERT or for INSERT or UPDATE UPDATE Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 29 Be Guoouse qnos 2 2 suondnos q 10113 2 2 2 7 Troubleshooting Event name Unregistered DB Map Variable Event code 5401 300A hex Meaning The specified DB Map Variable has not been registered Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end accordi
322. s assigned to the MapVar input variable to DB_CreateMapping_Update_instance WhereCond STRING 256 This variable is assigned to the Where input variable to DB_CreateMapping_Update_instance DB_Update_instance DB_Update Instance of DB_Update instruction Trigger_Update BOOL FALSE Variable used as a trigger for updating DB records RS_Update_instance RS Instance of RS instruction Operating_Update BOOL FALSE The DB_Update instruction is executed when this variable is TRUE OperatingEnd_Update BOOL FALSE This variable changes to TRUE when the DB_Update instruction is completed DB_Close_instance DB_Close Instance of DB_Close instruction Trigger _Close BOOL FALSE Variable used as a trigger for closing the DB Connection RS_Close_instance RS Instance of RS instruction Operating_Close BOOL FALSE The DB_Close instruction is executed when this variable is TRUE OperatingEnd_Close BOOL FALSE This variable changes to TRUE when the DB_Close instruction is completed NJ series Database Connection CPU Units User s Manual W527 A 23 suoljonujsu uonosuuon gq J w C 5 a v D 5 a v D J W J O Q Appendix A 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_Update_instance Done OperatingEnd_Connect _ DB_Connect_instance Error DB_Creat
323. s executed when this variable is TRUE Stage INT Variable that shows the status of the DB Connection Sample Programming Establish a DB Connection named MyDatabase1 and map a table with a variable Start the sequence when the variable Trigger_Connect changes to TRUE IF Trigger_Connect TRUE AND LastTrigger_Connect FALSE AND _DBC_Status Run TRUE THEN OperatingStart_Connect TRUE Operating_Connect TRUE END_IF LastTrigger_Connect Trigger_Connect Sequence start processing IF OperatingStart_Connect TRUE THEN Initialize the instances of the applicable DB Connection Instructions DB_Connect_instance Execute FALSE DB_CreateMapping_Insert_instance Execute FALSE MapVar MapVar_Insert SQLType _DBC_SQLTYPE_INSERT DB_CreateMapping_Update_instance FALSE MapVar_Update Execute MapVar SQLType _DBC_SQLTYPE_UPDATE Stage INT 1 OperatingStart_Connect FALSE END_IF Establish the DB Connection named MyDatabese1 NJ series Database Connection CPU Units User s Manual W527 A 29 J W O O 5 5 o QO O 5 gt A 2 c QO O 3 na puodey ga aw pdn spd ga Appendix A Map the variable MapVar_Insert to the table Production of the DB Connection MyDB7 for the INSERT operation Map the variable MapVar_Update to the table Production of the DB Connection MyDB1 for the UPDATE operation IF Operating_Connec
324. s for CJ series Unit Built in EtherNet IP Calculating Times on the Physical Controller When the project consists of one primary periodic task check the average task execution time using the Task Execution Time Monitor function of Sysmac Studio while online with the physical Controller Design the task using the following as a guideline Average task execution time lt Task period x 0 8 When the project consists of multiple tasks test performance under all foreseeable conditions on the actual system and make sure that the DB Connection Instructions are executed within the appropriate execution time before starting actual operation NJ series Database Connection CPU Units User s Manual W527 B 5 Lae SWI UOIINDEXy BdIAIBS Wa ShS y Bulyo9yD v 4 g ainpsco0ig ubiseq ysel g Appendix B B 2 Execution Time of DB Connection Instructions This section describes execution time of DB Connection Instructions B 2 1 Restrictions to Execution Time of DB Connection Instructions Execution time of DB Connection Instructions varies according to the following factors Status of the NJ series CPU Unit e DB type e Processing capability and load status of the server that contains the DB Contents of the SQL statement to execute Due to the above factors execution time of a DB Connection Instruction may exceed the reference value given in B 1 1 Reference Values for Execution Time of DB Connection Instructions The following
325. s for Correct Use When a DB Connection Instruction Execution Timeout occurred for a DB_ Select instruction the values of the retrieved record are not stored in the MapVar in out variable When a DB Connection Instruction Execution Timeout occurs repeatedly reconsider the task design and the server environment that contains the DB NJ series Database Connection CPU Units User s Manual W527 Index aa Index Index Adding a DB Connection cecescesceseceeeeteeseenseeneeeeesees 2 7 Assumed CAUSEC cccccccccescssssseeceeecesssseeeceecesseseaeeeeees 7 8 7 10 Backup Restore Function in the DB Connection DEPVICE e or EEEE E ee EE EE EE SE 5 23 Changing the DB Connection Name eeeseeeeeeteeees 2 7 Checking the Status of each DB Connection 4 12 Checking the Status of the DB Connection Service 4 8 Clearing the Mapping of DB Map Variables 3 12 Clearing the SQL Statements from the Spool Memory 5 7 Columns a a Sree aati een Communications Test Communications Timeout ccccccccccccessccessssecessseeeesseees 5 21 Connected time Connection name Connection Settings sesser s Te E R 2 8 Connection Status Microsoft Exce l nyireni dee eda ees gt Correspondence of Data Types between NJ series Controllers and DBrnsutisercere iin nse teo g Creating a Structure Data Type Data Already Spooled c ccccccccccscesseecssecssecesec
326. s section describes the Run mode of the DB Connection Service and start stop procedures 4 1 1 Run Mode of the DB Connection Service The DB Connection Service has two Run modes Operation Mode and Test Mode You can change the Run mode according to whether to actually access the DB This section describes the operations and usage of each Run mode of the DB Connection Service fl Run Mode of the DB Connection Service You can change the Run mode according to the purpose In Test Mode you can test the operations of the DB Connection Service without connecting to the DB In Operation Mode you can perform practical operation or trial operation by connecting to the DB Run mode Description Usage Environment Test Mode SQL statements are not sent to the DB when Operation check of When the DB does not DB Connection Instructions are executed user program using exist DB Connection Instructions end normally DB Connection or However the instructions for retrieving from Instructions when the when the DB exists but the DB do not output anything to the specified DB is not connected not connected DB Map Variable Spool function is disabled Operation SQL statements are sent to the DB when DB Practical or trial When the DB is connected Mode Connection Instructions are executed operation of the Spool function is enabled system when the DB is connected 4 1 2 How to Start Stop the DB Connection Service You ca
327. s to the columns of each table DB Refers to a database in a server DB Connection Refers to a virtual communication path established between CPU Unit and DB DB Connection function Used to connect a CPU Unit to a DB This function operates on a CPU Unit DB Connection Instruction Refers to special instructions for the DB Connection Service DB Connection Service This service provides the DB Connection function to connect a CPU Unit to a DB DB Connection Service shutdown function Used to shut down the DB Connection Service after automatically saving the Operation Log files into the SD Memory Card DB mapping Means to assign each member of a DB Map Variable to the corresponding column of a table in the connected DB DB Map Variable Refers to a variable that uses a structure data type for DB access as its data type Debug Log One of the Operation Logs This log is used for recording which SQL statements are executed and parameters and execution result of each SQL statements EM Area Refers to EM Area of the memory for CJ series Units The data in this area are retained even if the power supply to the CPU Unit is cycled i e ON OFF ON or the operating mode of the CPU Unit is changed i e PROGRAM mode lt RUN mode Execution Log One of the Operation Logs This log is used to record the executions of the DB Connection Service Operation Log Used to trace the op
328. scarded without being stored in the Spool memory Instruction Operation DB_Insert The SQL statement INSERT is not sent to the DB Insert DB An instruction execution error occurs Error TRUE Record SendStatus _DBC_SEND_SENDING Refer to Appendix DB Connection Instructions for ErrorID of the instruction execution error DB_Update The SQL statement UPDATE is not sent to the DB Update DB An instruction execution error occurs Error TRUE Record SendStatus _DBC_SEND_SENDING Refer to Appendix DB Connection Instructions for ErrorID of the instruction execution error Operations of Instructions and DB Connection Service in the Case of DB Connection Instruction Execution Timeout SUOI ONJISU UOOBUUOD gq 94 YIM diysuoNejay 8 L G When a DB Connection Instruction Execution Timeout occurs the transmitted SQL statement is stored in the Spool memory The DB Connection Service waits for a response from the DB for the time set in the Query execution timeout parameter plus 10 seconds after the DB Connection Instruction is executed When a response is returned from the DB the SQL statement stored in the Spool memory is deleted If no response has been returned from the DB when the time set in the Query execution timeout parameter plus 10 seconds has elapsed the DB Connection is changed to the Disconnected status If a DB_Insert Insert DB Record DB_Update Update DB Record DB_ Select Retrieve DB Record or DB_Dele
329. series Controllers and DB The correspondence of data types between NuJ series Controllers and DB is given in the following table Oracle Data type 7 Data type in DB Data type in NJ series Controllers category Characters VARCHAR2 STRING NVARCHAR2 STRING CHAR STRING NCHAR STRING LONG None CLOB None NCLOB None Numbers NUMBER 1 BOOL NUMBER 3 SINT NUMBER 5 INT NUMBER 10 DINT NUMBER 19 LINT NUMBER 3 USINT NUMBER 5 UINT NUMBER 10 UDINT NUMBER 20 ULINT NUMBER 19 TIME BINARY_FLOAT REAL BINARY_DOUBLE LREAL FLOAT REAL INTEGER DINT Date DATE DATE TIMESTAMP DATE DATE_AND_TIME TIMESTAMP WITH TIMEZONE DATE_AND_TIME TIMESTAMP WITH LOCAL TIMEZONE DATE_AND_TIME 3 4 NJ series Database Connection CPU Units User s Manual W527 3 Programming the DB Connection Function patallype Data type in DB Data type in NJ series Controllers category INTERVAL YEAR TO MONTH None INTERVAL DAY TO SECOND None Binary RAW None LONG RAW None BLOB None Others BFILE None ROWID None UROWID None XMLTYPE None 1 A NULL character is attached to the end of each text string Therefore you need to set the value that is one byte bigger than the number of bytes of the DB s data type for the number of bytes to be used in STRING data You need to set an appropriate value for the number of bytes used in the STRING data ac
330. settings Sysmac Studio Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is given Attached information 3 Instruction Name and Instruction Instance Name Where Error Occurred If there is more than one instruction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 35 Bee Guloouse qnol z suondnos q 10113 2 2 2 7 Troubleshooting Event name Data Already Spooled Event code 5401 3014 hex Meaning One or more SQL statements are already stored in the Spool memory Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None ay Cause and Assumed cause Correction Prevention correction A DB_Insert or DB_Update None None instruction was executed when one or more SQL statements were already stored in the Spool memory A DB_Select
331. statement is stored in the Spool memory 5 Disabled ErrorlD 3011 hex DB Connection Disconnected Error 7 Status SendStatus _DBC_SEND_ SENDING When executing Disconnected ErrorlD 3011 Hex DB Connection Disconnected Error a DB_ Select or Status DB_Delete SendStatus _DBC_SEND_ SENDING instruction When resending Disconnected Enabled The SQL statement is stored in the Spool memory again Spool data 5 4 5 Instruction Execution Timeout Refer to 5 1 8 Relationship with DB Connection Instructions for details on the instruction execution timeout INOS WI SUOIEDIUNWWOD p p G 5 4 6 Keep Alive Monitoring Time Whether the server is normally connected is monitored while the DB Connection is in the Connected status When the connection to the server cannot be confirmed for the time set in the Keep Alive monitoring time parameter plus 12 seconds due to a communications failure or server s problem the DB Connection is closed The DB Connection is changed to the Disconnected status when Spool data is resent or a DB_Insert Insert DB Record DB_Update Update DB Record DB_ Select Retrieve DB Record or DB_Delete Delete DB Record instruction is executed after the DB Connection is closed The keep alive function operates as shown below in the DB Connection Service Regardless of the Keep Alive setting the function is always used Regardless of the Linger option setting the option is always specified The operat
332. stem is Hardware User s Manual NJ301 basic provided along with the following information on specifications of the CPU Unit the NJ series e Features and system configuration CPU Units e Introduction including e Part names and functions introductory General specifications information e Installation and wiring designing e Maintenance and inspection installation and Use this manual together with the NJ series CPU maintenance Unit Software User s Manual Cat No W501 Mainly hardware information is provided NJ series CPU Unit W501 NJ501 Learning how to The following information is provided ona Software User s Manual NJ301 program and set Controller built with an NJ501 NJ301 CPU Unit up an NJ series CPU Unit operation CPU Unit Mainly e CPU Unit features software Initial settings information is Programming based on IEC 61131 3 language provided specifications Use this manual together with the NJ series CPU Unit Hardware User s Manual Cat No W500 Nu series Instructions W502 NJ501 Learning detailed The instructions in the instruction set IEC Reference Manual NJ301 specifications on 61131 3 specifications are described When the basic programming use this manual together with the instructions of an NJ series CPU Unit Hardware User s Manual NJ series CPU Cat No W500 and NJ series CPU Unit Unit Software User s Manual Cat No W501 NJ series Troubleshooting W503 NJ501 Learning about Concepts on mana
333. sumed cause Level Maj Prt Min Obs Info Reference 14D0 0000 hex Spool Memory Corrupted The Spool memory is corrupted The user application made an invalid writing to the Spool memory 14D20000 hex Execution Log Save Failed Failed to save the Execution Log to the SD Memory Card An SD Memory Card is not inserted The SD Memory Card is not the correct type of card The format of the SD Memory Card is not correct The SD Memory Card is write protected The capacity of the SD Memory Card is insufficient The SD Memory Card is damaged 14D3 0000 hex SQL Execution Failure Log Save Failed Failed to save the SQL Execution Failure Log to the SD Memory Card An SD Memory Card is not inserted The SD Memory Card is not the correct type of card The format of the SD Memory Card is not correct The SD Memory Card is write protected The capacity of the SD Memory Card is insufficient The SD Memory Card is damaged 3530 0000 hex DB Connection Setting Error The DB Connection settings are not correct The power supply to the Controller was interrupted during a download of the DB Connection settings The DB Connection settings are not correct because the power supply to the Controller was interrupted during a Clear All Memory operation The DB Connection settings are not
334. t Millisecond lt tab gt Category lt tab gt Log code lt tab gt Log name lt tab gt Result lt tab gt DB Connection name lt tab gt Serial ID lt tab gt Details lt CR gt lt LF gt Parameter Size Description Serial number 1 to 5 bytes 0 to 65535 When exceeding 65535 this value returns to 0 The serial number is given across multiple files Even if a new file is created the serial number is not reset to 0 Date 10 bytes Fixed Displays year month and date when the log was recorded x YYYY MM DD Example 2012 07 23 Time 8 bytes Fixed Displays hours minutes and seconds when the log was recorded hh mm ss Example 15 33 45 Millisecond 3 bytes Fixed Displays 3 digit decimal integer 000 to 999 that shows millisecond of the time when the log was recorded Example 10 ms 010 Q T K QO gt oO Q x Q gt 40 02 O m m x lt oO QO c O 7m g c ond oO m O Q 623 ms 623 Category 16 bytes max Variable Displays the category Log code 4 bytes Fixed Displays a 4 digit decimal code that is a unique identification code in the category Log name 32 bytes max Variable Displays a name that shows the contents of the log NJ series Database Connection CPU Units User s Manual W527 6 19 6 How to Use Operation Logs Parameter Size Description Result 6 bytes Fixed Displays a 4 digit hexadecimal code tha
335. t No Set the instance name or port number of the server Oracle Port No e g 1521 SQL Server Instance name or Port No e g INSTANCE1 or 1433 Maximum number of characters for instance name 64 characters Port No 1 to 65535 Default Blank This setting can be omitted When omitted the default port number is used Oracle 1521 SQL Server 1433 Service name Database name Set the service name or database name in the server Oracle Service name SQL Server Database name Maximum number of bytes 127 bytes This setting can be omitted When omitted Oracle Default service SQL Server Default database User name Set the user name for the server sBulyjas uoyo uuop gd 2 2 2 Maximum number of characters 127 characters Default Blank Password Set the password for the server Maximum number of characters 127 characters Default Blank Login timeout Set the timeout to be applied when connecting to the DB 1 to 60 seconds Default 10 seconds Query execution timeout Set the timeout to be applied at the SQL execution 1 to 600 seconds Default 30 seconds Comment Enter a comment Maximum number of bytes 1 024 bytes Default Blank The comment can be omitted When you specify a server by its host name you need to set DNS to Use or make the host settings in the Built in EtherNet IP Port Settings Refer to the NJU series CPU
336. t TRUE THEN CASE Stage OF 1 Establish the DB Connection DB_Connect_instance Execute TRUE DBConnectionName _ MyDatabase1 DBConnection gt MyDB1 IF DB_Connect_instance Done TRUE THEN Stage INT 2 Normal end END_IF IF DB_Connect_instance Error TRUE THEN Stage INT 99 Error END_IF 2 Map the DB table with the variable DB_CreateMapping_Insert_instance Execute TRUE DBConnection MyDB1 TableName Production MapVar MapVar_lInsert SQLType DBC_SQLTYPE_INSERT DB_CreateMapping_Update_instance Execute TRUE DBConnection MyDB1 TableName Production MapVar MapVar_Update SQLType _DBC_SQLTYPE_UPDATE IF DB_CreateMapping_Insert_instance Done TRUE AND DB_CreateMapping_Update_instance Done TRUE THEN Operating_Connect FALSE Normal end END_IF IF DB_CreateMapping_Insert_instance Error TRUE OR DB_CreateMapping_Update_instance Error TRUE THEN Stage INT 99 Error END_IF 99 Execute the error handler Program the error hander FaultHandler_Connect according to the device FaultHandler_Connect A 30 NJ series Database Connection CPU Units User s Manual W527 Appendix A Operating_Connect FALSE END_CASE END_IF Insert production data to DB Connection MyDB1 when the variable Trigger_Insert changes to TRUE Start the sequence when the variable Trigger_Insert changes to TRUE IF Tr
337. t can be created in a DB Connection i e 64 DB Map Variables is exceeded When 32 or more DB Connection Instructions were executed at the same time J W O O 3 5 oO QO O 5 gt A 2 c QO O 3 na den aq 21319 Buiddey jerequn ga Sample Programming Refer to the sample programming that is provided for the DB_Update instruction NJ series Database Connection CPU Units User s Manual W527 A 13 Appendix A DB_ Insert Insert DB Record The DB_Insert instruction inserts values of a DB Map Variable to a table of the connected DB as a record Instruction DB_Insert Name FB FUN Insert DB FB Record Graphic expression DB_Insert_instance DB_Insert Execute DBConnection MapVar TimeOut Done Busy Error ErrorlD SendStatus ST expression DB_Insert_instance Execute DBConnection MapVar TimeOut Done Busy Error ErrorlD SendStatus Note The DB_Insert_instance is an instance of DB_Insert instruction which is declared as a variable Variables i Input Variables Name Meaning Data type Valid range Unit Default Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition DBConnection DB Connection DWORD 16 00000000 to 16 0000 Specify the DB Connection established 16 FFFFFFFF 0000 by a DB_Connect instruction MapVar DB Map Structure Depends on the Specify the DB Map Variable mapped Variabl
338. t shows the execution result e g 0x1234 0x0000 Succeeded Other than 0x0000 Failed Same code as ErrorID of DB Connection Instruction DB Connection 16 bytes max Variable Displays a DB Connection name single byte alphanumeric name characters Serial ID 10 bytes max Variable ID code given at each execution of DB_Insert DB_Update DB_ Select or DB_Delete instruction The same ID as Serial ID displayed in the SQL or SQL Resend record of Execution Log is displayed Details Variable Displays the details of the SQL Execution Failure Log The contents differ according to the category In the Details parameter information items are separated from each other by a tab Category SQL Execution Failed Table name lt tab gt DB Map Variable name lt tab gt DB error code lt tab gt Error message lt tab gt SQL statement DB Map Variable name The POU instance name is not displayed DB error code Error code that is specific to DB vendor of the device to connect When a network error has occurred 0 is displayed for DB error code in some cases When 0 is displayed check the Result parameter Category Spooled Table name lt tab gt DB Map Variable name lt tab gt SQL statement DB Map Variable name The POU instance name is not displayed Category Status Error Table name lt tab gt DB Map Variable name lt tab gt SQL statement DB Map Variable name The POU instance name is not displayed Tab se
339. t this item when you select Auto for Do not clear Default Resend spool data At power ON Set the condition for clearing the SQL statements from the Spool memory When DB connection service started When DB connection established NJ series Database Connection CPU Units User s Manual W527 5 5 uoloun4 oods G sOulmes uoloun oods S 5 Other Functions 5 1 6 How to Resend the SQL Statements Stored in the Spool Memory You can resend the SQL statements stored in the Spool memory automatically or manually which can be selected in the Resend Spool Data of the Spool Settings Auto Resend The SQL statements stored in the Spool memory are automatically resent when the DB is reconnected CPU Unit Server Program fe DB Connection Service N 1 Reconnected Relational Database e INSERT EtherNet IP Bs EM Area 1 When communications are recovered i e when non volatile memory the DB is reconnected SQL statements stored in the Spool memory are automatically resent in Spool memory the spooling order INSERT INSERT INSERT j Manual Resend The SQL statements stored in the Spool memory are resent when a DB_ControlSpool Resend Clear Spool Data instruction is executed All of the SQL statements stored in the Spool memory are sent in th
340. tabase Connection CPU Units User s Manual W527 A 5 Appendix A DB_ Connect Establish DB Connection The DB_Connect instruction connects to a specified DB Instruction Name FB FUN Graphic expression ST expression DB_ Connect Establish FB f DB_Connect_instance Execute DB DB_Connect_instance DBConnectionName Done Busy Connection DB_Connect Error ErroriD DBConnection Execute Done DBConnectionName Busy Error ErrorlD DBConnection Note The DB_Connect_instance is an instance of DB_Connect instruction which is declared as a variable Variables f Input Variables Name Meaning Data type Valid range Unit Default Description Execute Execute BOOL TRUE or FALSE FALSE Specify the execution condition DBConnectionName DB STRING 17 bytes max g Specify a DB Connection name Connection including the final set on Sysmac Studio Name NULL character Output Variables Name Meaning Data type Valid range Unit Description Done Done BOOL TRUE or ane TRUE when the instruction is normally completed FALSE Busy Executing BOOL TRUE or ae TRUE when the instruction is being executed FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to an FALSE error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF DBConnection DB DWORD 16 00000000 Outputs a DB Connection Connection to Specify this DB Connection
341. table None uniqueidentifier None xml None 1_ Integer in units of nanoseconds 2 The significant figures are 15 digits When the data is written to the DB by a DB Connection Instruction a value rounded to four decimal places is written 3 The significant figures are 7 digits When the data is written to the DB by a DB Connection Instruction a value rounded to four decimal places is written 4 The accuracy is milliseconds 5 A NULL character is attached to the end of each text string Therefore you need to set the value that is one byte bigger than the number of bytes of the DB s data type for the number of bytes to be used in STRING data You need to set an appropriate value for the number of bytes used in the STRING data according to the data type and character code in the DB In NJ Series text strings are handled as UTF 8 One byte is used for each single byte alphanumeric character and multiple bytes are used for each multi byte character Three bytes are used for each Japanese character as a guide 3 2 3 How to Create a Structure Data Type for DB Access You can use the following procedures for creating a structure data type for accessing a DB Entering the data on the Data Type Editor Pasting the data from Microsoft Excel onto the Data Type Editor This section gives brief explanation for the operations Refer to the Sysmac Studio Version 1 Operation Manual Cat No W504 for detailed operations j Entering the
342. te Delete DB Record instruction is executed while the DB Connection Service is waiting for a response from the DB an error DB in Process occurs for the instruction NJ series Database Connection CPU Units User s Manual W527 5 9 5 Other Functions 5 10 DB _Insert Insert DB Record or DB_Update Update DB Record Instruction If the Spool function is enabled the SQL statement to send is spooled Regardless of the Resend spool data setting the spooled SQL statement is sent after the response to the previous DB Connection Instruction is returned DB Select Retrieve DB Record or DB_Delete Delete DB Record Instruction To execute the DB_ Select Retrieve DB Record or DB_Delete Delete DB Record instruction after the response to the previous DB Connection Instruction is returned write the user program so that the execution of the DB_Select Retrieve DB Record or DB_Delete Delete DB Record instruction is retried until it is normally completed La Precautions for Correct Use If the time set in the Query execution timeout parameter has elapsed after execution of a DB Connection Instruction a cancel request of the applicable SQL operation is sent to the DB The details of the SQL operation cancel processing are given below 1 When the cancel processing is completed within 10 seconds lt The instruction will be terminated due to an error SQL Execution Error 2 When the cancel processing is not completed within 10 seco
343. th the CPU Unit NJ series Database Connection CPU Units User s Manual W527 7 3 7 Troubleshooting Checking with the Troubleshooting Function of Sysmac Studio When an error occurs you can connect Sysmac Studio online to the Controller to check current Controller errors and the log of past Controller errors You can also check the cause of the error and corrections Refer to the NJ series Troubleshooting Manual Cat No W503 for the procedures to check for errors with Sysmac Studio i Checking with the Troubleshooter of an NS series PT If you can connect communications between an NS series PT and the Controller when an error occurs you can check for current Controller errors and the log of past Controller errors You can also check the cause of the error and corrections Refer to the NJU series Troubleshooting Manual Cat No W503 for the procedures to check for errors with an NS series PT i Checking with Instructions That Read Error Status You can use instructions in the user program to check the error status of each function module The following table gives the instruction that is used to get error information for the DB Connection Service Instruction Name Function GetPLCError Get PLC Error Status The GetPLCError instruction gets the highest level status partial fault or minor fault and highest level event code of the current Controller errors in the PLC Function Module For details on the instructions that get e
344. the DB Connection Service and then start the service again p ues aq JouUeDd 10 paddojs si 3919S uoyosuuo gd L v NJ series Database Connection CPU Units User s Manual W527 4 5 4 Basic Operations and Status Check 4 2 Establishing Cosing a DB Connection After starting the DB Connection Service you establish or close a DB Connection using an instruction as shown below Establishing a DB Connection Use a DB_Connect Establish DB Connection instruction to establish a DB Connection with a specified name A Precautions for Correct Use Mapping to the DB is automatically cleared when the DB Connection is closed Therefore write the user program so that a DB_Connect Establish DB Connection instruction is executed before a DB_CreateMapping Create DB Map instruction is executed Closing a DB Connection Specify the DB Connection name given in the DB_Connect Establish DB Connection instruction in a DB_Close Close DB Connection instruction and execute the instruction Refer to Appendix DB Connection Instructions for details of each instruction 4 6 NJ series Database Connection CPU Units User s Manual W527 4 Basic Operations and Status Check 4 3 Checking the Status of DB Connection Service and each DB Connection This section describes how to check the following status DB Connection Service e Each DB Connection 4 3 1 Operation Status of the DB Connection Service This section describes the operation stat
345. the Error output variable changes from FALSE to TRUE The previous DB Response Time is held The new DB Response Time is stored when a normal response is returned from the DB after the instruction execution timeout SpoolDataCnt Number of Spool Data INT Number of SQL statements stored in the Spool memory for the DB Connection SpoolUsageRate Spool Usage SINT Use rate of the Spool memory for the DB Connection The unit is percentage ErrorDateTime Disconnection Date Time DATE_AND_TIME Date and time the last time the connection was disconnected due to an error SQLSTATE SQL Status STRING 8 Error code defined in SQL Standards ISO IEC 9075 for disconnection ErrorCode Error Code DINT Error code for disconnection which is specific to DB vendor ErrorMsg When a network failure or an SQL Execution Error occurred SendStatus Output variable SendStatus Error Message Meaning Send Status _eDBC_SEND_STATUS STRING 128 Data type Error message for disconnection which is specific to DB vendor Description Enumeration data type that shows transmission status of the SQL statement to DB _DBC_SEND_INIT 0 Initial status _DBC_SEND_UNSENT 1 SQL statement unsent _DBC_SEND_SENDING 2 Sending SQL statement _DBC_SEND_SPOOLED 3 SQL statement spooled _DBC_SEND_COMPLETE 4 SQL statement transmission completed NJ series
346. the user can set the event level the event 7 Remarks levels that can be set the recovery method operational information and other information is also provided 1 One of the following I Major fault Major fault level N Partial fault Partial fault level ae Minor fault Minor fault level Observation Q Information a 2 One of the following 8 Automatic recovery Normal status is restored automatically when the cause of the error is removed 5 Error reset Normal status is restored when the error is reset after the cause of the error is removed 5 n Cycle the power supply Normal status is restored when the power supply to the Controller is turned OFF and then back ON after the cause of the error is removed Controller reset Normal status is restored when the Controller is reset after the cause of the error is removed Depends on cause The recovery method depends on the cause of the error 3 One of the following System System event log Access Access event log 4 One of the following Continues Execution of the user program will continue Stops Execution of the user program stops Starts Execution of the user program starts NJ series Database Connection CPU Units User s Manual W527 7 15 7 Troubleshooting j Errors Related to DB Connection Service Event name Spool Memory Corrupted Event code 14D0 0000 hex Meaning The Spool memory is corrupted Source PLC Function Module Sou
347. thing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks NJ series Database Connection CPU Units User s Manual W527 7 27 Bee Guoouse qnol z 7 SUONdOSEq 10113 2 2 2 7 Troubleshooting Event name Invalid DB Connection Event code 5401 3008 hex Meaning The specified DB Connection is not correct or the DB Connection is already closed Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None Cause and Assumed cause Correction Prevention correction The DB Connection specified in Specify a correct DB Connection Confirm that a correct DB the DBConnection input variable in the DBConnection input variable Connection is specified in the of the relevant instruction is of the relevant instruction DBConnection input variable of the wrong relevant instruction The DB Connection specified in Correct the user program so that Write the user program so that the the DBConnection input variable the relevant instruction is executed relevant instruction is executed of the relevant instruction is after the DB Connection is after the DB Connection is closed established by a
348. tilisation de ce logiciel est a votre seule risque et p ril Microsoft n accorde aucune autre garantie expresse Vous pouvez b n ficier de droits additionnels en vertu du droit local sur la protection des consommateurs que ce contrat ne peut modifier La ou elles sont permises par le droit locale les garanties implicites de qualit marchande d ad quation a un usage particulier et d absence de contrefa on sont exclues LIMITATION DES DOMMAGES INT R TS ET EXCLUSION DE RESPONSABILIT POUR LES DOMMAGES Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement hauteur de 5 00 US Vous ne pouvez pr tendre aucune indemnisation pour les autres dommages y compris les dommages sp ciaux indirects ou accessoires et pertes de b n fices Cette limitation concerne tout ce qui est reli au logiciel aux services ou au contenu y compris le code figurant sur des sites Internet tiers ou dans des programmes tiers et les r clamations au titre de violation de contrat ou de garantie ou au titre de responsabilit stricte de n gligence ou d une autre faute dans la limite autoris e par la loi en vigueur Elle s applique galement m me si Microsoft connaissait ou devrait conna tre l ventualit d un tel dommage Si votre pays n autorise pas l exclusion ou la limitation de responsabilit pour les dommages indirects accessoires ou de quelque nature que ce soit il se peut
349. tion Trigger_Select BOOL FALSE Variable used as a trigger for retrieving DB records RS_Select_instance RS Instance of RS instruction Operating_Select BOOL FALSE The DB_Select instruction is executed when this variable is TRUE OperatingEnd_Select BOOL FALSE This variable changes to TRUE when the DB_ Select instruction is completed WhereCond_Delete STRING 256 This variable is assigned to the Where input variable to DB_Delete_instance Request_Delete BOOL FALSE The DB_Delete instruction is executed when this variable is TRUE DB_Delete_instance DB_Delete Instance of DB_Delete instruction RS_Delete_instance RS Instance of RS instruction Operating_Delete BOOL FALSE The DB_Delete instruction is executed when this variable is TRUE OperatingEnd_Delete BOOL FALSE This variable changes to TRUE when the DB_Delete instruction is completed DB_Close_instance DB_Close Instance of DB_Close instruction Trigger _Close BOOL FALSE Variable used as a trigger for closing the DB Connection RS_Close_instance RS Instance of RS instruction Operating _Close BOOL FALSE The DB_Close instruction is executed when this variable is TRUE OperatingEnd_Close BOOL FALSE This variable changes to TRUE when the DB_Close instruction is completed NJ series Database Connection CPU Units User s Manual W527 A 43 O Ww O O 5 5 oO QO O 5 D o c QO O 5 D j q ga p10094 gq 819129 Append
350. tion Service STEP 8 Starting the DB Connection Service Reier lo 4 Basic Operations and Status Check Use any of the following methods to start the DB Connection Service e Automatically start the service when the operating mode of the CPU Unit is changed from PROGRAM mode to RUN mode Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Online Settings from the menu Then click the Start Test Mode or Start Operation Mode Button Execute a DB_ControlService Control DB Connection Service instruction Specify the following Run mode when starting the DB Connection Service When the specified DB does not exist in the server or when the DB exists but not connected Specify the Test Mode When the specified DB is connected Specify the Operation Mode Refer to 3 5 2 DB Connection Instruction Set and Appendix DB Connection Instructions STEP 9 Executing DB Connection Instructions Confirm that the operation status of the DB Connection Service is Running with the _DBC_Status Run system defined variable Running flag of the DB Connection Service and then execute the DB Connection Instructions STEP 10 Debugging the DB Connection Refer to 3 6 Debugging Instructions in Design Startup and Operation Phases 1 10 NJ series Database Connection CPU Units User s Manual W527 1 Introduction
351. tion in this manual is classified as follows Precautions for Safe Use Precautions on what to do and what not to do to ensure safe usage of the product A Precautions for Correct Use Precautions on what to do and what not to do to ensure proper operation and performance Ee Information Additional information to read as required This information is provided to increase understanding or make operation easier Version Information Information on differences in specifications and functionality for CPU Units with different unit versions and for different versions of the Sysmac Studio is given Note References are provided to more detailed or related information Precaution on Terminology In this manual download refers to transferring data from Sysmac Studio to the physical Controller and upload refers to transferring data from the physical Controller to Sysmac Studio For Sysmac Studio synchronization is used to both upload and download data Here synchronize means to automatically compare the data for Sysmac Studio on the computer with the data in the physical Controller and transfer the data in the direction that is specified by the user 4 NJ series Database Connection CPU Units User s Manual W527 Sections in this Manual Sections in this Manual Introduction to the DB Connection Service DB Connection Settings Programming the DB Connection Function Basic Operations and Status C
352. to Manual Clear condition Do not clear v Reset all to default N E T E MMMM Refer to Section 5 1 Spool Function for detailed settings 2 10 NJ series Database Connection CPU Units User s Manual W527 Programming the DB Connection Function BE e This section describes programming procedure from variable creation to DB access after making the DB Connection settings 3 1 DB ACCESS Proced re oaeiio eikean eeaeee aaa a aae aa ae eatea EET 3 2 3 2 Creating a Structure Data Type s ssesessesssssrsessrrnnsrrrnnarrnnnsrrrnnnsinrnnesennnnrnenne 3 3 3 2 1 EE AEE E EA EAE T ENET EA EEEE 3 3 3 2 2 Specifications of Structure Data Type for DB Access 08 3 3 3 2 3 How to Create a Structure Data Type for DB ACCESS 0 08 3 6 3 3 Creating a DB Map Variable eee eeceeeceeeeneeeeeeeeeeeeeseneeeeeseneaeeeenneaeeeeee 3 9 3 3 1 DB Map Variables and DB Mapping cceeseseeeeeeeteeeeeeetteeeeteee 3 9 3 3 2 Registration and Attributes of DB Map Variables 0 c 3 10 3 3 3 Restrictions on DB Map Variables cccccccesceceeeeessteeeeeneeeeenees 3 11 3 4 Specifying the Table and Applying the Mapping cceesesseeeeeseeeeeee 3 12 3 4 1 DB Mapping by Executing a Create DB Map Instruction 3 12 3 4 2 Clearing the Mapping of DB Map Variables cceeeeeeee 3 12 3 4 3 Restrictions on DB Mapping ce ceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
353. to TRUE when processing is completed Use this to confirm normal completion of processing Refer to Using this Section of the NJ series Instructions Reference Manual Cat No W502 for a timing chart for Execute Done Busy and Error This instruction cannot be used on an event task A compiling error will occur When the DB Connection Service was started in Test Mode this instruction is completed normally without connecting to the DB actually An error occurs for this instruction in the following cases Error will be TRUE was in progress already closed Sample Programming is used to close the DB Connection specified in the DBConnection input variable When the instruction was executed when the DB Connection Service was not running When the instruction was executed while the initialization processing of the DB Connection Service When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down When the value of the DBConnection input variable is invalid or the specified DB Connection is When 32 or more DB Connection Instructions were executed at the same time Refer to the sample programming that is provided for the DB_Update instruction A 10 NJ series Database Connection CPU Units User s Manual W527 Appendix A DB_CreateMapping Create DB Map
354. to Use Operation Logs 6 3 6 Checking the Debug Log 6 3 7 6 14 Refer to 6 6 Checking the Operation Logs for how to check the Debug Log Debug Log File Specifications This section describes the specifications of Debug Log files e Each Debug Log file is composed of multiple records The maximum size of each Debug Log file is set in Sysmac Studio The size of each record is 58 KB max The following table shows the file name and type File name File type DB_DebugLog log Latest log file of the log DB_DebugLog_ year_month_date_hours_minutes_seconds_milliseconds log Previous log files Example DB_DebugLog_20120724220915040 log DB_DebugLog fjc Log control file The system time of the CPU Unit is used for the time information included in the file name The files are stored in the following directory of the SD Memory Card Log files packages DB_Connection DebugLog Log control file packages DB_Connection System The record format is shown below Each record is expressed in one line and composed of multiple parameters The parameters are separated from each other by a tab Serial number lt tab gt Date lt tab gt Time lt tab gt Millisecond lt tab gt Category lt tab gt Log code lt tab gt Log name lt tab gt Result lt tab gt DB Connection name lt tab gt Serial ID lt tab gt Details lt CR gt lt LF gt Parameter Size Description Serial number 1 to 5 bytes 0
355. to Use Operation Logs Log file example 1 2012 07 24 09 00 00 150 SQL 0001 INSERT 0x0000 MyDatabase1 45 TABLE_Production Production INSERT INTO TABLE_Production Column1 VALUES 1000 2 2012 07 24 09 00 00 200 SQL RESULT 0001 INSERT 0x300B MyDatabase1 46 17072 ORA 17072 Inserted value too large for column Precautions for Correct Use Do not delete the latest log file DB_DebugLog log and the log control file DB_DebugLog fjc from the SD Memory Card If they are deleted the log files are not saved correctly for example the Debug Log data are lost P oo O oT Ko o amp suoljeoyioads aji4 607 Bnq q 7 9 NJ series Database Connection CPU Units User s Manual W527 6 17 6 How to Use Operation Logs 6 4 SQL Execution Failure Log 6 4 1 6 4 2 6 4 3 6 18 This section describes the SQL Execution Failure Log used to trace the execution failures of the DB Connection Service due to a DB caused factor Overview You can check the SQL statements and error information when transmission of an SQL statement failed due to a problem of the DB itself For example Because the column names of the table have been changed they do not match the column names of an SQL statement sent from the DB Connection Service A value to insert is outside the valid range of the data type of the column You can record this log by setting SQL execution failure log to Record in the DB Connection
356. to the DB Connection Service STEP 11 Checking the Status with Sysmac Studio 4 Basic Operations and Status Check You can check the status of the entire DB Connection Service and the connection status of each DB Connection y JO MO 4 UO e19dO E L Lw W O e 5 5 fe fa 5 n D B fa Status of the entire DB Connection Service Right click DB Connection Service Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Monitor DB Connection Service from the menu Then check the status of the entire DB Connection Service on the monitor Connection status of each DB Connection Right click DB Connection Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Connection Monitor Table from the menu You can check the connection status of each DB Connection STEP 12 Checking the Operation Logs eelet ies ow ieee Operation Logs You can check the following Operation Logs for tracing the operations of the DB Connection Service on the CPU Unit e Execution Log This log is used to trace the executions of the DB Connection Service Logging is kept while the DB Connection Service is running 7 Right click DB Connection under Configurations and Setup Host Connection Settings and select Show Operation Logs from the menu and click the Execution Log Tab e
357. truction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was shut Shutting Down down or while the DB Connection Service was being shut down 3008 hex Invalid DB Connection The value of the DBConnection input variable is invalid or the specified DB Connection is already closed 300A hex DB Map Variable Unregistered The variable specified in the MapVar input variable has not been mapped by a DB_CreateMapping instruction 300B hex SQL Execution Error The executed SQL statement resulted in an error in the DB 300C hex Spool Capacity Exceeded The SQL statement cannot be stored in the Spool memory because its capacity is exceeded 3011 hex DB Connection Disconnected Error The DB Connection Service cannot communicate with the DB due to a Status network failure or other causes 3012 hex DB Connection Instruction Execution The instruction was not completed within the time specified in the TimeOut Timeout input variable 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3014 hex Data Already Spooled The SQL statement was spooled because one or more SQL statements are already stored in the Spool memory 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress 3016 hex DB in
358. tructured Text ST Main Variables Appendix A Name Data type Initial value Comment DB_GetServiceStatus_instance DB_GetServiceStatus Instance of DB_GetServiceStatus instruction Trigger BOOL FALSE Variable used as a trigger for getting the status of the DB Connection Service LastTrigger BOOL FALSE Variable to retain the trigger status of the previous execution Operating BOOL FALSE The DB_GetServiceStatus instruction is executed when this variable is TRUE OperatingStart BOOL FALSE The initialization processing is executed when this variable is TRUE MyStatus _sDBC_SERVICE_STATUS This variable is assigned to the ServiceStatus input variable to DB_GetServiceStatus_instance Warning BOOL FALSE This variable changes to TRUE when the number of error executions is 100 or greater NJ series Database Connection CPU Units User s Manual W527 A 63 w W O O 5 5 oO QO O 5 D o c QO O 5 D SNYEIGSIIAIBSIEH gd SNIE1S BDIAI S UOIID9 UUOD gq 185 Appendix A Sample Programming Start the sequence when the variable Trigger changes to TRUE IF Trigger TRUE AND LastTrigger FALSE THEN OperatingStart TRUE Operating TRUE END_IF LastTrigger Trigger Sequence start processing IF OperatingStart TRUE THEN Initialize the instruction instance DB_GetServiceStatus_instance Execute FALSE OperatingStart FALSE END_IF IF
359. tus of the DB Connection Service is Shutdown NJ series Database Connection CPU Units User s Manual W527 4 Basic Operations and Status Check DB Connection Service is Stopped The DB Connection Service is stopped in the following cases e When the DB Connection Service is stopped by a DB_ControlService Control DB Connection Service instruction or Sysmac Studio e When the operating mode of the CPU Unit is changed to PROGRAM mode When the Synchronization download operation is executed regardless of whether the DB Connection settings are transferred When the Clear All Memory operation is executed When the Restore Controller operation is executed from Sysmac Studio e When a major fault level Controller error has occurred e When the DB Connection Service is shut down Eb additional Information If you stop the DB Connection Service when it is waiting for a response from the DB after sending an SQL statement the DB Connection Service is stopped after it receives the response from the DB or a communications error is detected If a DB Connection has been established when the DB Connection Service is stopped the DB Connection is closed SOINIOS UOI DBUUOD gq JO POW UNH L s Np 201d dojs els pue 4 1 4 Changing the Run Mode of the DB Connection Service You cannot change the Run mode of the DB Connection Service between Operation Mode and Test Mode while the service is running To change the Run mode stop
360. u can check the following operation information of the DB Connection Service using a DB_GetServiceStatus Get DB Connection Service Status instruction Information Description Debug Log flag TRUE while the Debug Log is recorded Operating time Time elapsed since the DB Connection Service was started When the DB Connection Service is stopped the time from start to stop is retained This value is cleared the next time the DB Connection Service is 9J S UOIBUUOD gq 8U JO SNIS aU BuIy99YD Z y started Number of normal Total number of times in all connections when an SQL statement is executions normally executed Including the number of times when a spooled SQL statement is resent This value is cleared when the DB Connection Service is started Number of error executions Total number of times in all connections when an SQL statement execution failed This value is cleared when the DB Connection Service is started Number of Spool data Number of spooled SQL statements in all connections The Debug log flag remains TRUE even if recording to the log is stopped in the following cases When the When the log is full parameter is set to Stop logging in the Service Settings and the maximum number of files is reached When the SD Memory Card capacity is insufficient When writing to the SD Memory Card failed NJ series Database Connection CPU Units User s Manual W527 4 9 4 Basic Operations and Stat
361. uction all of them are given If the instruction cannot be identified nothing is given Attached information 4 Expansion Error Code ErrorIDEx Precautions None Remarks Event name DB Connection Disconnected Error Status Event code 5401 3011 hex Meaning The instruction could not be executed because the DB Connection had been disconnected due to an error Source PLC Function Module Source details Instruction Detection At instruction timing execution Error attributes Level Observation Recovery Log category System Effects User program Continues Operation The relevant instruction will end according to specifications System defined Variable Data type Name variables None ato Cause and Assumed cause Correction Prevention correction The power supply to the serveris Check the server status and start it Check the server status and start it OFF properly properly The DB is stopped in the server The Ethernet cable connector is Reconnect the connector and Connect the connector securely disconnected make sure it is mated correctly The Ethernet cable is broken Replace the Ethernet cable None Noise Implement noise countermeasures Implement noise countermeasures if there is excessive noise if there is excessive noise Attached Attached information 1 Error Location information Attached information 2 Error Location Detail Rung Number For a program section the rung number from the start of the section is given For ST the line number is
362. urs for the instruction is longer than the time set for the timeout An error occurs for this instruction in the following cases Error will be TRUE When the instruction was executed when the DB Connection Service was not running When the instruction was executed while the initialization processing of the DB Connection Service was in progress When the instruction was executed while the DB Connection Service was stopped due to an error When the instruction was executed after the DB Connection Service was shut down or while the DB Connection Service was being shut down When the value of the DBConnection input variable is invalid or the specified DB Connection is already closed When the variable specified in the MapVar input variable has not been mapped by a DB_CreateMapping instruction When the Where input variable is a text string consisting of NULL characters 16 00 only When the value of the Timeout input variable is outside the valid range When the executed SQL statement resulted in an error in the DB When the DB Connection Service cannot communicate with the DB due to a network failure or other causes When the SQL statement cannot be spooled because the Spool capacity is exceeded When one or more SQL statements are already stored in the Spool memory When the instruction was not completed within the time specified in the TimeOut input variable When the instruction was executed before completion of the DB s
363. us Check i Checking the Status with a System defined Variable 4 10 You can check the operation status of the DB Connection Service with the _DBC_Status system defined variable Use this variable when checking the status of the DB Connection Service from the user program or checking the shutdown of the DB Connection Service from an HMI _DBC_Status system defined Status variable Member Meaning Initializing Running Running Idle Error Shut Operation Test down Mode Mode Run Running flag FALSE TRUE TRUE FALSE FALSE FALSE Test Test mode FALSE FALSE TRUE FALSE FALSE FALSE Idle Idle FALSE FALSE FALSE TRUE FALSE FALSE Error Error stop flag FALSE FALSE FALSE FALSE TRUE FALSE Shutdown Shutdown FALSE FALSE FALSE FALSE FALSE TRUE NJ series Database Connection CPU Units User s Manual W527 4 Basic Operations and Status Check 4 3 3 Connection Status of each DB Connection This section describes the connection status of each DB Connection DB Connection Service Started DB Connection Closed DB Connection Service Stopped or Shutdown Can be reconnected Disconnected due to a network failure or server problem J Cannot be established DB Connection Established UOJOSUUOD gq JO sNyeIS ayy Buoy p UOIJO9UUOD gq Yee pue S Cannot be reconnected Reconnected DB Connection Closed DB Connection Service Stopped or Shutdown Each DB Connection
364. us of the DB Connection Service Power ON An error occurred ea ee The error removed se aint rae La beta Gees so Service Started in bi Test Mode Running Running Test Mode Operation Mode Shut down Shut down hut down Shutdown uolJOaUUOD gq JO SNWIS ayy Buyo9YD p UOI JO9UUOD gq YOeS pue S Shut down The DB Connection Service has six operation statuses nitializing Idle Running Operation Mode Running Test Mode Error Shutdown After the power supply to the CPU Unit is turned ON the DB Connection Service enters the Initializing status When the initialization processing is completed the service enters the dle status If the DB Connection Service settings are invalid in the d e status the service enters the Error status When the error is removed the service returns to the Idle status When the DB Connection Service is started the service enters the Running Operation Mode or Running Test Mode status according to the Run mode of the DB Connection Service When the DB Connection Service is stopped in the Running Operation Mode or Running Test Mode status the service enters the Idle status When the DB Connection Service shutdown function is executed the service enters the Shutdown status The following table gives the details of each status Status Description Remarks Initializing The DB Connection Service was The DB Connection Service cannot be started started but has not entered the Idle
365. ved records The records up to the maximum number of elements in the DB Map Variable are output For example in the case where 30 records are retrieved for the DB Map Variable with 10 array elements the records from MapVar 0 to MapVar 9 are retrieved The value of RecCnt will be 10 and the value of SelectedCnt will be 30 in this case When the number of array elements of the DB Map Variable is bigger than gt the number of retrieved records The records up to the number of elements of the retrieved records are output For the later elements the records are not retrieved but the previous values are retained For example in the case where 3 records are retrieved for the DB Map Variable with 10 array elements the records from MapVar 0 to MapVar 2 are retrieved The values of MapVar 3 to MapVar 9 do not change The value of RecCnt will be 3 and the value of SelectedCnt will be also 3 in this case The records are retrieved according to the retrieval conditions specified in the Where input variable WHERE clause The Where input variable is expressed as a text string The text string in the Where input variable cannot consist of NULL characters 16 00 only In that case the instruction is terminated due to an error Specify the sort conditions in the Sort input variable ORDER BY clause to sort out the retrieved records The Sort input variable is expressed as a text string When the sort conditions are specified the records are c
366. vice connection disconnection with the DB and success failure of SQL statement executions with the Execution Log Thus you can check whether the expected DB Connection Service processing is executed You can record this log by setting Execution log to Record in the DB Connection Service Settings of Sysmac Studio You can also record a specified log as Execution Log by executing a DB_PutLog Record Operation Log instruction When you record this log the Execution Log file is constantly saved on the SD Memory Card mounted in the CPU Unit while the DB Connection Service is running The Execution Log is temporarily recorded in the internal buffer volatile memory of the CPU Unit and then saved on the SD Memory Card While the SD Memory Card is being replaced the Execution Log is kept in the internal buffer volatile memory of the CPU Unit When you insert an SD Memory Card the Execution Log temporarily stored in the internal buffer are automatically saved on the SD Memory Card Refer to 6 5 3 Operation Log Operations in Replacing the SD Memory Card for details You can check the contents of this log in the Execution Log Tab Page of the Operation Log Window in Sysmac Studio H Precautions for Correct Use When you use the Execution Log be sure to insert an SD Memory Card into the CPU Unit The Execution Log is temporarily recorded in the internal buffer of the CPU Unit and then saved on the SD Memory Card If no SD Memory Card is mounted at
367. ware User s Manual Cat No W501 for the procedure to check the operation in the Simulator Design the task using the following as a guideline Estimated CPU usage rate System service execution time ratio lt 80 The estimated CPU usage rate shows the percentage of the total of the following times in the task period Estimated maximum value of the task processing time Tag data link service execution ratio Required system service processing time for system service monitoring The value found by subtracting the system service execution ratio from the estimated CPU usage rate is the percentage for the execution time of processing other than system services NJ series Database Connection CPU Units User s Manual W527 Appendix B bA Primarylask Task Execution Time ee Average Estimation 226us Max Estimation 346us Set period 1000us Period exceeded Task execution count 40683 times Real processing time of tasks 226 us Syslem common processing IO refresh Execution of user programi Motion Control v f PeriudicTasko Task Execution Time EIT Average Estimation 248us Max Estimation 368us Set penod 10000us Penod exceeded Task execution count 4093 times Real processing time of tasks 22us System common processing I O refresh Execution of user program Motion Control System service execution ratio 10 Estimated CPU usage rate 32 Tag data link service execution ratio 0 Reset Expanded number of I O point
368. x Input Value Out of Range The value of the TimeOut input variable is outside the valid range 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same time Same Time 3000 hex DB Connection Service not Started The instruction was executed when the DB Connection Service was not running 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was shut Shutting Down down or while the DB Connection Service was being shut down 3008 hex Invalid DB Connection The value of the DBConnection input variable is invalid or the specified DB Connection is already closed 300A hex DB Map Variable Unregistered The variable specified in the MapVar in out variable has not been mapped by a DB_CreateMapping instruction 300B hex SQL Execution Error The executed SQL statement resulted in an error in the DB 300E hex Invalid Retrieval Conditions The Where input variable is a text string consisting of NULL characters 16 00 only 3011 hex DB Connection Disconnected Error Status The DB Connection Service cannot communicate with the DB due to a network failure or other causes 3012 hex DB Connection Instruction Execution The instruction was not completed within the time specified in the Timeout TimeOut input variable 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3014 hex Data Already Spooled
369. xecuted FALSE Error Error BOOL TRUE or TRUE when the instruction is terminated due to FALSE an error ErrorlD Error Code WORD 16 0000 to Contains the error code when an error occurs 16 FFFF A 78 NJ series Database Connection CPU Units User s Manual W527 Related Error Codes Appendix A Error code Meaning Description 0400 hex Input Value Out of Range A value that is not defined as an enumerator was specified in the LogType input variable 041D hex Too Many Instructions Executed at the 32 or more DB Connection Instructions were executed at the same Same Time time 1400 hex SD Memory Card Access Failure The SD Memory Card is not available 1401 hex SD Memory Card Write protected The SD Memory Card is write protected 3002 hex DB Connection Service Shutdown or The instruction was executed after the DB Connection Service was Shutting Down shut down or while the DB Connection Service was being shut down 3010 hex Log Code Out of Range The value of the LogCode input variable is outside the valid range 3013 hex DB Connection Service Error Stop The instruction was executed while the DB Connection Service was stopped due to an error 3015 hex DB Connection Service Initializing The instruction was executed while the initialization processing of the DB Connection Service was in progress 3017 hex Operation Log Disabled The log cannot be recorded because the specified Operation Log is disable
370. xecuting an instruction that sends an SQL statement An example user program is given below Measurement example of DB response time for a DB_Insert instruction Find the DB response time for a DB_Insert instruction DB_Insert_instance DB_GetConnectionStatus_instance Operating DB_Insert DB_GetConnectionStatus Execute Done Execute Done MyDatabase1 DBConnectionName Busy MyDB1 DBConnection Busy MapVar_Insert MapVar Error Error TimeOut ErrorlD ErrorlD SendStatus ConnectionStatus MyStatus Normal end processing Operating DB_Insert_instance Done DB_GetConnectionStatus_instance Done Output the DB response time to DB1ResTimel variable __ H DB1ResTime index MyStatus DBResTime Index index 1 IF index 1000 THEN Index 0 END_IF You can also check the DB response time with the Execution Log or Debug Log NJ series Database Connection CPU Units User s Manual W527 B 9 SUOI ONJISU UONO UUOD gq JO duly uonno xa z g ow asuodsey gq aunseeyy 0 MOH Z g Appendix B B 2 4 Ensuring Equipment Performance Takt Time by Monitoring Instruction Execution Timeout If you do not want to lower the equipment performance or extend the takt time when the execution time of DB Connection Instruction is increased set a timeout for the instructions You can specify a timeout in the TimeOut input variable to the DB_Insert DB_ Update DB_Select and DB_ Delete
371. ysmac Studio DB_GetConnectionStatus Get DB Connection Status instruction Checking the Status with Connection Monitor Table of Sysmac Studio Right click DB Connection Settings under Configurations and Setup Host Connection Settings DB Connection in the Multiview Explorer and select Connection Monitor Table from the menu while online with an NJ series CPU Unit The following Connection Monitor Table Tab Page is displayed A Configurations and Setup LQ 4 Connection Name DBConnection01 Y Connection Status Connection Closed Connected time 0 00 54 43 481 Disconnected time 0 00 00 00 000 Disconnection date time 1 1 1970 0 00 00 000 v Query Execution Number of normal executions 0 Number of error executions 0 Response time 0 00 00 00 000 YW Spooling Number of spool data 0 Spool usage 0 Y Connection Error SQL status Error code Error message You can monitor the following of each DB Connection unless the operation status of the DB Connection Service is Idle or Shutdown Category Item Description Values Connection Connection Status of the DB Connection Closed Status Connected Disconnected Refer to 4 3 3 Connection Status of each DB Connection Connected time Total time when the DB is connected Duration This value is cleared when Connection changes from Unit d h m s ms Closed to Connected Disconnected time Total time when the DB is disconnected due to an Duration error Unit d h m
372. ytes 1 The system time of the CPU Unit is used for the time information 2 Category Category Characters displayed in the log DB Connection Service DB_SERVICE DB Connection DB_CONNECTION SQL SQL SQL Resend SQL_RESEND User specified Log USER NJ series Database Connection CPU Units User s Manual W527 6 7 6 How to Use Operation Logs 3 Code Category Code Operation Log recording timing decimal DB Connection 0001 DB Connection When the start processing of the DB Service Service Started Connection Service is completed succeeded failed 0002 DB Connection When the stop processing of the DB Service Stopped Connection Service is completed succeeded failed 0003 DB Connection When the shutdown processing of the DB Service Shutdown Connection Service is completed succeeded failed DB Connection 0001 DB Connection When the establishment processing of a DB Established Connection is completed succeeded failed after the establishment is commanded from Sysmac Studio or the applicable instruction 0002 DB Connection When the close processing of a DB Connection Closed is completed succeeded failed after the close is commanded from Sysmac Studio or the applicable instruction 0003 DB Connection When disconnection from the DB is detected Disconnected 0004 DB Connection When the DB Connection status changes from Reestablished Disconnected to Connected SQL 0001 INSERT W

Download Pdf Manuals

image

Related Search

Related Contents

  ANNEXE I RÉSUMÉ DES CARACTÉRISTIQUES DU PRODUIT  PWMinder User Guide - Ewert Technologies  Uni-Trend UT15B multimeter  Bedienungsanleitung - PointService Ratingen  ORTHOPHOS XG 5 / Ceph XG 3  Page 1 Page 2 Page 3 現場における土の乾燥単位体積重量試縮方法  Philips Sonicare AirFloss Pro HX8254  Manual GPESE/SISAAE -  第二弾!熱電対入力タイプの登場! - 株式会社コアーズ[記録できる2ch  

Copyright © All rights reserved.
Failed to retrieve file