Skip to main content
williamm0010
August 9, 2022
Question

Parameter Query in Cloud Database SQL Window

  • August 9, 2022
  • 10 replies
  • 0 views

I am newer to Appian and in the cloud database in the SQL window trying figure out how to do a Parameter Query.  I need to have the parameters in the query so it can be ran by other people as well on the fly.

I have this:

SELECT * FROM `accounts` WHERE `state` = :state and `county` = :county and `servcode` = :servcode and `area` = :area

How do I add these before the SELECT statement and give them the values?

so basically I want to be able to do something like this

@state = "IL",

@county = "Jackson",

@servcode = 2568   

etc....

Then the query use those to run

Thank you Bill

10 replies

stefanhelzle0001
Brainy
August 9, 2022

If found this in the documentation of phpMyAdmin

docs.phpmyadmin.net/.../faq.html

williamm0010
August 9, 2022

Yes found that and the bind parameters work just fine, but I need to be able to save these queries to a .sql file so anyone can run them as needed.  The parameters need to be set in each sql file for the select statement.  So I am trying to figure out how to write the sql to set the parameters and run the sql so it can be save in a .sql file so others can run the files when needed.

williamm0010
August 9, 2022

So the query has to be saved into a .sql file, the other users need to be able to go to the cloud database and import the .sql file for it to run.  So some how I need to see if there is a way to write the parameterized sql statement with the parameters defined and assigned values with the select statement.

stefanhelzle0001
Brainy
August 9, 2022

I do not know whether this is supported by phpMyAdmin.

What is the purpose of this? Why do others need to query data directly in the database?

williamm0010
August 9, 2022

There are other admins as well, and they are wanting .sql files written for queries they can run on the fly to check data, but they do not want to supply the parameters, they are wanting them set.  Not seeing anything that shows how to do this so you may not be able to....

williamm0010
August 9, 2022

So basically I am trying to create something like this in a .sql file to be able to use the import on the cloud database to run the query.

The below I can save to a .sql file and run it in sql server, now need to do something like this that will run in Appian from a .sql file.

DECLARE @state varchar(2) = 'IL',
DECLARE @county varchar(50) = 'Jackson',
DECLARE @servcode int = 54,
DECLARE @area int = 28

SELECT * FROM accounts
WHERE state = @state
and county = @county
and servcode = @servcode
and area = @area

csteward
August 9, 2022

Also, I'm assuming there is a reason you can't give them an admin type interface in Appian and query the data dynamically via a!queryEntity()?  We have a number of dynamic reports at the admin level to monitor data in the system, through Appian.

williamm0010
August 9, 2022

Thank you for the responses, we are going to go another route on this.   Thank you