Query database dynamic table name

Certified Lead Developer

Hi all,

I'm currently designing a post-deployment process and I need to be able to query database tables dynamically based on the application being deployed. I’ve tried using the Query Database smart service with variables such as ac!table, but I get an error each time.

I’ve also tried setting the full SQL statement in an ac! variable to create the complete query and pass it, but this approach hasn't been successful either.

Has anyone encountered a similar issue or can suggest a solution to dynamically query tables based on deployment context? Any insights would be greatly appreciated!

Thanks in advance!

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    I had a similar requirement to dynamically pass the column name, table name, and primary key as parameters. Since Appian doesn't support dynamic queries, I am planning to create a stored procedure in the database to handle this and use Execute stored procedure smart service instead of Query database. The procedure will accept these parameters and return the required result.

    However, I am also exploring the possibility of achieving this using a query entity or query record.

Reply
  • 0
    Certified Senior Developer

    I had a similar requirement to dynamically pass the column name, table name, and primary key as parameters. Since Appian doesn't support dynamic queries, I am planning to create a stored procedure in the database to handle this and use Execute stored procedure smart service instead of Query database. The procedure will accept these parameters and return the required result.

    However, I am also exploring the possibility of achieving this using a query entity or query record.

Children
No Data