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
10 replies
Subscribers
7 subscribers
Views
10008 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
General
Update single column in a table (Update single field in cdt)
Rama Thummala
Certified Lead Developer
over 7 years ago
Hi,
In Appian normally we will update a record by passing complete record with updated data.
I have a requirement to update single column in a table(updating single field in a record) instead of updating complete record.
like, update <table> <field>=<value> where <key>=<value>.
OriginalPostID-243101
Discussion posts and replies are publicly visible
0
rodgraham
Certified Lead Developer
over 7 years ago
You can create a data type with only the field you want to update and the key in it to achieve that using the write to data store node.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
charanrajkrishnap0001
A Score Level 1
over 7 years ago
You can write update query in Query Database Smart Service. Please refer the following
forum.appian.com/.../Query_Database_Smart_Service.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sparshs
over 7 years ago
yes you can first fetch the record from database and update the specific filed in the CDT . Then you can write the whole record back to database.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jaggu
over 7 years ago
Query Database Approach will be good, but Appian does not suggest that because its not a best practice.
If you configure Query database, after deployment to other environments then you to open the model and reconfigure it again (if data source changes).
You can create a datatype to update that particular field, but if you want to update column 1 in one model and column 2 in 2nd model and so on.
Then you cannot create so many data types for required columns to update.
My suggestion is that use Write to data store entity smart service and pass full CDT.
Because this will not result into any performance issue not manual update when data source changes.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
brettf
over 7 years ago
As @rodgraham mentioned above, what is called a "summary CDT" works well here. You make a CDT that, in the JPA annotations, maps to the correct table in the DB. It will have two fields:
the PK for that table
field you want to update
When you use a write to DB node in conjunction with this CDT, it will find the row in the table that corresponds to the PK of your CDT, and update the columns in the table that match up to the other fields in the CDT. You can use this to write one, or really as many fields as you want, which can be useful for various processes and events.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Rama Thummala
Certified Lead Developer
over 7 years ago
Thanks all.
I am trying with CDT.If the field is of type single(primitive) it is working fine.But the fields of type array it is mapping differently.
I could see that, if we are mapping from CDT to database for array type fields appain is creating seperate table, handling the operations differently(but working fine).
In my case when creating new CDT (summery CDT) for updation , again one more table is creating for array type fields, not mapping with existing one.I want it to map with existing tables.
How to handle this scenario?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sparshs
over 7 years ago
you can handle this in your xsd . Here you can map your cdt to your existing table.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Rama Thummala
Certified Lead Developer
over 7 years ago
@sparshs
Please find the below sample case.Can you please help me on this?
Actual CDT:
\tEmployee
\ t-id int -PK
\ t-name text
\ t-skills text array
\ t-dept text
\ t-some other fields etc
\t
Update CDT:\t
\tUpdateEmployee
\ t-id int -PK
\ t-dept text
\ t-skills text array
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sparshs
over 7 years ago
I think you have not gone through my earlier point. You should download the xsd of update CDT and map it to your existing table. I hope you are able to get my point.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
rodgraham
Certified Lead Developer
over 7 years ago
Take a copy of the xsd for the full table and then remove any of the fields you don't want, change the name of the cdt to something else and upload it, map it to data store. This would then point to existing table
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel