Editing Database Data Using a Data Manipulator
A Data Manipulator allows to execute a generic SQL query, on demand. For more information, refer to Data Sources and Data Manipulators and Create a Data Manipulator.
There are three possible ways to use Data Manipulators to edit database data from GraphWorX:
NOTE: These procedures use the SQL Server database, RollerChainManufacturing, and the UpdateBadParts Data Manipulator described in Create a Data Manipulator, as an example.
To edit database data using a Data Manipulator via inline parameters:
-
Open GraphWorX. From the Dynamics ribbon, select Data Entry, and then click in the canvas and drag the rectangle to add and size the control. The Data Entry is added to the screen, and the Data Source box is selected in the Property Grid.
-
Click on the three dots button in the Data Source box to launch the Data Browser. Expand the Data Manipulator you want to execute, and select the @@Execute tag. Select OK to confirm your choice.
NOTE: To follow the example, navigate to the UpdateBadParts Data Manipulator.
-
Notice how the tag name in the Data Source box references the @@Execute tag, and the Data Manipulator's parameters with default values.
NOTE: If you selected the UpdateBadParts Data Manipulator from the example, the @BadParts, @Equipment and Timestamp parameters are added to the tag name with default values:
db:RollerChainManufacturing.UpdateBadParts<@BadParts=0, @Timestamp='10/30/2024 12:00:00 AM', @Equipment=''>.@@Execute
-
Modify the values of the parameters with the desired values. Click Runtime in the upper right corner of GraphWorX, or use the key combination CTRL+M, to start runtime mode. The Data Entry displays 0.00.
NOTE: To follow the example, use the following values for the UpdateBadParts Data Manipulator. You must enter the value for @Timestamp using your local regional settings, if different from English (United States).
db:RollerChainManufacturing.UpdateBadParts<@BadParts=1005, @Timestamp='6/1/2020', @Equipment='100-Line'>.@@Execute
-
Select the Data Entry, write the value 1 and press ENTER. The Data Manipulator will be executed with the parameter values specified in the tag name, and the database will be updated. A success message will be displayed in the status bar, and the Data Entry will revert automatically to its value of 0.00.
TIP: You can make parameter values in the tag name dynamic by using Global or Local Aliases.
To edit database data using a Data Manipulator via explicit parameters:
-
Open GraphWorX. From the Dynamics ribbon, select Data Entry, and then click in the canvas and drag the rectangle to add and size the control. The Data Entry is added to the screen, and the Data Source box is selected in the Property Grid.
-
Click on the three dots button in the Data Source box to launch the Data Browser. Expand the Data Manipulator you want to execute, and select the @@Execute tag. Select OK to confirm your choice.
NOTE: To follow the example, navigate to the UpdateBadParts Data Manipulator.
-
Add a new Data Entry, and click the three dots button in the Data Source box. In the Data Browser, expand the Data Manipulator you want to execute, and expand Parameters to show the parameters list.
NOTE: To follow the example, select the @Timestamp parameter.
-
Repeat the process by adding Data Entry controls for each parameter of the Data Manipulator.
NOTE: To follow the example, add two more Data Entry controls for the @Equipment and @BadParts parameters. For the @BadParts Data Entry set the DecimalPlaces to 0. For more information, refer to Edit database using a Data Entry.
-
Click Runtime in the upper right corner of GraphWorX, or use the key combination CTRL+M, to start runtime mode. The Data Entry for the @@Execute tag displays 0.00. The other data entries display the parameter's default value.
-
Select each Data Entry for the parameters, enter the desired parameter value and press ENTER. Then, select the Data Entry for the @@Execute tag, write 1 and press ENTER. The Data Manipulator will be executed with the parameter values specified in the Data Entries, and the database will be updated. A success message will be displayed in the status bar, and the Data Entry will revert automatically to its value of 0.00.
NOTE: to follow the example, use the following parameter values:
Parameter Value Notes @Timestamp 6/1/2020 You must enter the value for @Timestamp using your local regional settings, if different from English (United States). @Equipment 100-Line @BadParts 1010 TIPS:
- The parameter values entered in the Data Entry controls will override the values specified in the @@Execute tag.
- If there is no Data Entry control for a parameter, the value specified in the @@Execute tag will be used.
To edit database data using a Data Manipulator using a method call:
-
Open GraphWorX. From the Dynamics ribbon, select Button under Buttons, and then click in the canvas and drag the rectangle to add and size the control. The button is added to the screen.
-
In the property grid, under the Dynamic Behavior section select the value next to the Command label. Click the chevron button to expand the list, and select Call Method under Global Commands.
-
In the property grid, under CommandParameters select the value next to the Name value. Click the chevron button to display the options, and select Browse/Edit... to launch the Data Browser.
-
In the Data Browser, expand the Data Manipulator you want to execute, and select the Execute method. The method name populates the Name field.
NOTE: To follow the example, select the Execute method under the UpdateBadParts Data Manipulator.
-
In the property grid, under CommandParameters select the value next to the Parameters value. Click the three dots button to display the CallMethodParameterData Collection Editor dialog.
-
Use the dialog to configure the Data Manipulator parameter values. Select Add to create a new parameter, and use the property grid to specify the parameter's value and data type. Parameter values must follow these rules:
- Only values for Input or Input/Output parameters must be specified. For more information about parameter directions, refer to Create a Parameterized Data Source.
- Parameters values must be specified in the same order in which they are defined in the Data Manipulator's parameters list in Workbench. For more information, refer to Create a Data Manipulator, step 9.
NOTE: To follow the example, enter the following method parameters, in this order:
Value ValueType Notes 1030 Int32 This is the @BadParts parameter. 6/1/2020 DateTime This is the @Timestamp parameter. You must enter the value for @Timestamp using your local regional settings, if different from English (United States). 100-Line String This is the @Equipment parameter. -
Select OK to close the CallMethodParameterData Collection Editor dialog.
-
Click Runtime in the upper right corner of GraphWorX, or use the key combination CTRL+M, to start runtime mode. Click the button: the Data Manipulator will be executed with the parameter values specified in the command configuration, and the database will be updated.