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
3885 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Process
Hello, I am trying to write an INSERT query for DB2 using the Query D
thanosm
over 10 years ago
Hello,
I am trying to write an INSERT query for DB2 using the Query Database Node that in some cases sets the value of VARCHAR field to NULL while in other cases it inserts an actual value.
The INSERT query is of the form "INSERT INTO <table> (..., <VARCHAR FIELD>", ...) VALUES (..., ac!VarcharField, ...)"
How can i write the expression for the value of the parameter ac!VarcharField so that it sets the Field to have a NULL value, depending on a condition, in the database?
Generally, in DB2, you set the field to NULL using the expression "CAST(NULL AS VARCHAR(10))".
Thanks for the help....
OriginalPostID-121205
OriginalPostID-121205
Discussion posts and replies are publicly visible
0
Aleksi White
Appian Employee
over 10 years ago
Rather than doing this directly in the SQL statement, you could do it beforehand in a script task. Set up a script task node prior to the query database node. Then have the script task run some if() statement logic to determine whether ac!VarcharField should be null or have an actual value
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
thanosm
over 10 years ago
How can i define the ac!VarcharField (DataType Text) to have a null value?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Aleksi White
Appian Employee
over 10 years ago
null is reserved in Appian, so you can just set up a data input or output and assign 'null' (without the quote marks) to ac!VarcharField
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
thanosm
over 10 years ago
Thank you for your help. However, even with assigning 'null' to the parameter ac!VarcharField, the respective DB field contains an empty string value ('') and not a NULL value.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Aleksi White
Appian Employee
over 10 years ago
Are you sure that the value of ac!VarcharField isn't being overwritten anywhere else after it is given null?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
thanosm
over 10 years ago
Yes, i am sure that the value of ac!VarcharField is not being overwritten by another value. I have also tried this functionality on a new test process model that only executes the same INSERT query and it ONLY provides the value 'null' to ac!VarcharField. The resulting value in the DB field is always the same.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Aleksi White
Appian Employee
over 10 years ago
Is the field in the database configured as "NOT NULL"?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
thanosm
over 10 years ago
No, the field is configured to allow NULL values.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Jason Ruvinsky
Certified Lead Developer
over 10 years ago
We're using MS SQLServer, but we also have the issue that whenever using write to datastore entity and passing in nulls, Appian passes empty strings to varchar fields "". We have an enhancement request for this issue with reference number AN-53545. We've had to work around this by either accepting "" in the database, creating smaller CDTs that don't include the fields that are being left null (only works if we know those fields wouldn't be populated in that process), having triggers on the database that will set the fields to null, or using the Execute stored procedure plugin and creating stored procedures for our data writes.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel