Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
9 replies
Subscribers
6 subscribers
Views
3537 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Process
I am interested in saving a group of process variables to a data store, and sele
Mike
over 12 years ago
I am interested in saving a group of process variables to a data store, and selectively deleting rows in that data store, or modifying particular entities in the data store. I have not come upon the correct combination of settings that will allow me to do this using combinations of "Delete from Data Store Entity" or using "Query Database". I seem to be adding to my data store when I try to delete, which is described in the documentation if my index is wrong. I am trying to use a process variable as my index, but its a multiple variable, so it looks like "; 3" if I try to delete the third row in my table. Any quick and simple suggestions on how to modify or delete data in data stores?...
OriginalPostID-62243
OriginalPostID-62243
Discussion posts and replies are publicly visible
0
akhilan
over 12 years ago
Do you have a column which is a primary key for the table? If yes, you can use the primary key value to delete a record. In the XSD of your CDT you can annotate the primary key by using @Id. For more on such annotations you can refer Appian documentation -
forum.appian.com/.../Defining_a_Custom_Data_Type
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike
over 12 years ago
No, the 24 pages of documentation didn't quite answer my question. I will keep working on it until I find a solution.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Annelise Dubrovsky
Appian Employee
over 12 years ago
Michael, here's an example of an XSD snippet where an "id" field of a CDT is marked as the primary key:
<xsd:element name="id" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Id
@GeneratedValue
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
You need the annotation with an appinfo that has "appian.jpa" as its source. @Id indicates that this field is a PK. This is the minimum that you need in order to correctly update your rows in the DB using the Write to Data Store Entity smart service, and to delete rows using the Delete from Data Store Entities smart service.
@GeneratedValue is useful if you want your primary key values to be auto-generated each time you insert a row into the DB using the Write to DS smart service. It's a commonly used configuration.
After you've updated your XSD and reimported your CDT (
forum.appian.com/.../Managing_Custom_Data_Types
, the "id" field will now be the PK field.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Annelise Dubrovsky
Appian Employee
over 12 years ago
Once you have the CDT set up with a primary key mapping, and you've republished your Data Store, you can try using the Write to DS node to create a row. Save the node output into a PV and check that the "id" field (or whichever field you marked as your PK field) and make sure it has the generated id if you're using @GeneratedValue.
Then modify the CDT value and call the Write to DS node again, with the id field populated with the id of the row that you want to update. Similarly, use the same id with the Delete from DS node.
Let us know if you need clarification on any of the above!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike
over 12 years ago
Annalise,
That's quite helpful! I'm getting a much more exciting class of error messages now.
Thanks for your guidance and assistance.
Mike
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Annelise Dubrovsky
Appian Employee
over 12 years ago
You're welcome! We should be able to help sort out the error messages if you don't have it working yet. Let us know how it goes.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike
over 12 years ago
Here's the start of my schema. It ignores the @ID etc and generates a_id anyway:
xsd:schema
targetNamespace="
scrippsnetworksdev.appiancloud.com/.../"
xmlns:types611="
scrippsnetworksdev.appiancloud.com/.../"
xmlns:xsd="
www.w3.org/.../XMLSchema">
<xsd:complexType name="RR_Resource">
<xsd:annotation>
<xsd:documentation><![CDATA[The CDT to contain information for all employees.]]></xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="empID_Int" nillable="true" type="xsd:int"/>
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Id
@GeneratedValue
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="employee_ID" nillable="true" type="xsd:int"/>
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Mike
over 12 years ago
When I import the xsd file I receive this error message at the bottom of the Preview and Confirm New Data Types box:
XSD Parsing Message: XSD: The element '
www.w3.org/.../XMLSchema
is not permitted as constrained by '
www.w3.org/.../XMLSchema
expecting any | sequence | choice | group | element | nothing (APNX-2-4047-000)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Annelise Dubrovsky
Appian Employee
over 12 years ago
In your example, you have a closing tag in both the empID_int and employee_ID elements.
The annotation needs to be *within* the element that you want to mark as the PK.
<xsd:element name... >
<xsd:annotation>
</xsd:annotation>
</xsd:element>
Notice how your "<xsd:element name..." ends with "/>" instead of ">". Here's an updated snippet:
<xsd:element name="empID_Int" nillable="true" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="appian.jpa">
@Id
@GeneratedValue
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel