Skip to main content
April 11, 2022
Question

Can I execute a if statement in Query Database

  • April 11, 2022
  • 4 replies
  • 0 views

Hi Team

I have a requirement where I need to generate different update query statements for different tables depending on some conditions in a  process model.
Do we have any feature to implement this? 
I do not want to use a XOR gate and create different nodes from XOR condition as the query statements may be huge.
Or if we can generate the query statement in a Script Task and directly call the query to update the tables in the process model.
We use Appian version 21.1

Thank you!!

    4 replies

    stefanhelzle0001
    Brainy
    April 11, 2022

    You can write an expression rule which creates a list of CDTs which can be inserts and updates based on input data.

    Can you share a few more details?

    April 11, 2022

    Hi Stefan,

    My condition would be something similar in the rule expression : 

    if (field 1 ="Test", 

    update table1 set table_col=ac!value where primarykey=ac!key,

    if (field 1 ="Test1",

    update table2 set table_col=ac!value where primarykey=ac!key,

    null))

    table1 and table2 are two different tables with different structures.
    We may have more columns in set values and where clause

    stewart.burchell
    April 11, 2022

    I'm not sure why you wouldn't have an XOR that routes the processing to the appropriate Write to Datastore node. If the tables are different with different structures then you gain no benefit from trying to unify them in any way. Treat them as distinct entities and route your process flow accordingly.