"Using multiple id to update database"
When using "Update Database" operator, there is a description for "attribute filter type" says:
subset : This option allows the selection of multiple id attributes throught a list ...
My question is how to set multiple id attributes using "set role" operator, i have two attributes(machine_id & time_stamp) to set as id in order to update my orginal DB table, however, "set role" operator always keep lastest one attribute as id not both. Is there any way to set multiple attribute, or i misunderstand the description above?
by the way, i've tried using user define attribute set machine_id as id_1, time_stamp as id_2, but didn't work on "Update Database" operator, it will be recognized as different row.
Here is the operator.
<?xml version="1.0" encoding="UTF-8"?><process version="8.0.001">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="8.0.001" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="retrieve" compatibility="8.0.001" expanded="true" height="68" name="Retrieve labeled data" width="90" x="179" y="85">
<parameter key="repository_entry" value="//rm-server/projects/Model Management/generate data/labeled data"/>
</operator>
<operator activated="true" class="set_role" compatibility="8.0.001" expanded="true" height="82" name="Set Role" width="90" x="313" y="85">
<parameter key="attribute_name" value="Time_Stamp"/>
<parameter key="target_role" value="id"/>
<list key="set_additional_roles">
<parameter key="Machine_ID" value="id"/>
<parameter key="Time_Stamp" value="id"/>
</list>
</operator>
<operator activated="true" class="jdbc_connectors:update_database" compatibility="8.0.001" expanded="true" height="68" name="Update Database" width="90" x="447" y="85">
<parameter key="connection" value="rm_repository"/>
<parameter key="table_name" value="machine_sensors"/>
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attribute" value="Machine_ID"/>
<parameter key="attributes" value="Time_Stamp|Machine_ID"/>
</operator>
<connect from_op="Retrieve labeled data" from_port="output" to_op="Set Role" to_port="example set input"/>
<connect from_op="Set Role" from_port="example set output" to_op="Update Database" to_port="input"/>
<connect from_op="Update Database" from_port="through" to_port="result 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
</process>
</operator>
</process>
Appreciated,
Ray Jhong
Answers
Hi @RayJhong,
roles are unique. it is only possible to set each role once. However, if you choose more than one attribute in the selector of Update Database, it will take them for the update in the DB. This is independent of roles (except for the include special).
Best,
Martin
Dortmund, Germany
Hi @mschmitz
Thank you for quick reply, i've tried choosing both attribute as selector but got wrong result as below:
Result seems like it didn't treat Machine_ID & Time_Stamp as keys to update Failure, instead, it became a new row.
Hi,
have you tried "Include Special Attributes"? Otherwise, specials of your selection are ignored. Not very intuitive in this operator, but this is how it works.
Best,
Martin
Dortmund, Germany
Hi @mschmitz
The same result. and i also tried remove "set role" operator to prevent any special attribute to be excluded but nothing changes. Is is possible for you to reproduce my situation? here is the process:
And datasource is in Samples/Templates/Predictive Maintenance/reference data with a time_stamp capturing current date time.
Sincerely,
Ray Jhong